Created
February 12, 2012 22:59
-
-
Save Fogh/1811381 to your computer and use it in GitHub Desktop.
MailComposeViewController - Send email in iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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