Skip to content

Instantly share code, notes, and snippets.

@Fogh
Created February 12, 2012 22:59
Show Gist options
  • Save Fogh/1811381 to your computer and use it in GitHub Desktop.
Save Fogh/1811381 to your computer and use it in GitHub Desktop.
MailComposeViewController - Send email in iOS
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Notifies users about errors associated with the interface
switch (result)
{
case MFMailComposeResultCancelled:
break;
case MFMailComposeResultSaved:
break;
case MFMailComposeResultSent:
break;
case MFMailComposeResultFailed:
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Sending Failed - Unknown Error :-(" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
break;
}
[self dismissModalViewControllerAnimated:YES];
}
- (void)sendLinkInMail
{
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:self.link.title];
NSString *messageString = [NSString stringWithFormat:@"%@ - %@", self.link.title, self.link.url];
[mailController setMessageBody:messageString isHTML:NO];
if (mailController) [self presentModalViewController:mailController animated:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment