Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use the method below</p> <pre><code>-(void)displayComposerSheet { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Check out this image!"]; // Set up recipients // NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; // NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; // NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; // [picker setToRecipients:toRecipients]; // [picker setCcRecipients:ccRecipients]; // [picker setBccRecipients:bccRecipients]; // Attach an image to the email UIImage *coolImage = ...; NSData *myData = UIImagePNGRepresentation(coolImage); [picker addAttachmentData:myData mimeType:@"image/png" fileName:@"coolImage.png"]; // Fill out the email body text NSString *emailBody = @"My cool image is attached"; [picker setMessageBody:emailBody isHTML:NO]; [self presentModalViewController:picker animated:YES]; [picker release]; } </code></pre> <p>And implement the delegate method</p> <pre><code>- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { // Notifies users about errors associated with the interface switch (result) { case MFMailComposeResultCancelled: NSLog(@"Result: canceled"); break; case MFMailComposeResultSaved: NSLog(@"Result: saved"); break; case MFMailComposeResultSent: NSLog(@"Result: sent"); break; case MFMailComposeResultFailed: NSLog(@"Result: failed"); break; default: NSLog(@"Result: not sent"); break; } [self dismissModalViewControllerAnimated:YES]; } </code></pre> <p>And in your interface file</p> <pre><code>#import &lt;MessageUI/MFMailComposeViewController.h&gt; ... @interface ... : ... &lt;MFMailComposeViewControllerDelegate&gt; </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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