Objective C: Send email without leaving app

Yes. Use the MFMailComposeViewController.

// From within your active view controller
if([MFMailComposeViewController canSendMail]) {
    MFMailComposeViewController *mailCont = [[MFMailComposeViewController alloc] init];
    mailCont.mailComposeDelegate = self;

    [mailCont setSubject:@"yo!"];
    [mailCont setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
    [mailCont setMessageBody:@"Don't ever want to give you up" isHTML:NO];
    [self presentViewController:mailCont animated:YES completion:nil];

}


// Then implement the delegate method
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    [self dismissViewControllerAnimated:YES completion:nil];
}

Leave a Comment