Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this again may be you forgot small thing...i am not sure abt that.....you code looks fine.... it should work..</p> <p>First add and Import the MessageUI Framework</p> <pre><code>#import &lt;MessageUI/MessageUI.h&gt; </code></pre> <p>and Declare the MFMaileComposeViewControllerDelegate</p> <pre><code>@interface MailViewController : UIViewController &lt;MFMailComposeViewControllerDelegate&gt; </code></pre> <p>Write this code for sending the mail</p> <pre><code>- (IBAction)openMail:(id)sender { if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; mailer.mailComposeDelegate = self; [mailer setSubject:@"xyz"]; NSArray *toRecipients = [NSArray arrayWithObjects:@"fisrtMail@example.com", @"secondMail@example.com", nil]; [mailer setToRecipients:toRecipients]; NSString *emailBody = @"xyz"; [mailer setMessageBody:emailBody isHTML:NO]; [self presentModalViewController:mailer animated:YES]; [mailer release]; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" message:@"Your device doesn't support the composer sheet" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; } </code></pre> <p>}</p> <p>and also write the delegate method of MFMailComposeViewControllerDelegate</p> <pre><code>- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { switch (result) { case MFMailComposeResultCancelled: NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued."); break; case MFMailComposeResultSaved: NSLog(@"Mail saved: you saved the email message in the drafts folder."); break; case MFMailComposeResultSent: NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send."); break; case MFMailComposeResultFailed: NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error."); break; default: NSLog(@"Mail not sent."); break; } // Remove the mail view [self dismissModalViewControllerAnimated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload