How do I send an email within an app without leaving the app.
This works:
-(void) sendEmailTo:(NSString *)to withSubject:(NSString *)subject withBo
Updated for iOS 6. Please note that this uses ARC and does not use the deprecated modal view presentation:
#import
#import
@interface MyViewController : UIViewController
And then the code to present the email screen:
- (IBAction)emailButtonPushed:(id)sender {
if([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailCont = [[MFMailComposeViewController alloc] init];
mailCont.mailComposeDelegate = self;
[mailCont setSubject:@"Your email"];
[mailCont setMessageBody:[@"Your body for this message is " stringByAppendingString:@" this is awesome"] isHTML:NO];
[self presentViewController:mailCont animated:YES completion:nil];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
//handle any error
[controller dismissViewControllerAnimated:YES completion:nil];
}