Skip to content

Instantly share code, notes, and snippets.

@jenhausu
Created April 16, 2015 02:21
Show Gist options
  • Save jenhausu/2b41cd04567075d68fee to your computer and use it in GitHub Desktop.
Save jenhausu/2b41cd04567075d68fee to your computer and use it in GitHub Desktop.
<MFMailComposeViewControllerDelegate>
UIMessage.framework
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
break;
case MFMailComposeResultSaved:
break;
case MFMailComposeResultSent:
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
if ([MFMailComposeViewController canSendMail])
{
NSString *emailTitle = @"";
NSString *messageBody = @"";
NSArray *toRecipents = [NSArray arrayWithObject:@"[email protected]"];
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:emailTitle];
[mailViewController setMessageBody:messageBody isHTML:YES];
[mailViewController setToRecipients:toRecipents];
[self presentViewController:mailViewController animated:YES completion:NULL];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment