MFMailComposeViewController: exit with cancellation

I have the following code representing a user with email from an application:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Subject"]; NSString* link = [NSString stringWithFormat:@"<a href='%@'>Report</a>",link]; [picker setMessageBody:link isHTML:YES]; picker.navigationBar.barStyle = UIBarStyleDefault; [self presentModalViewController:picker animated:YES]; [picker release]; 

and allso:

 - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ [self dismissModalViewControllerAnimated:YES]; } 

everything works fine, expect that I want to cancel skip the draft delete / save draft / cancel scene and basically chose the delete draft (without presenting it to the user) can this be done? thanks

+4
source share
1 answer
 - (void)mailComposeController:(MFMailComposeViewController *) controller didFinishWithResult:(MFMailComposeResult) result error:(NSError *)error { switch (result) { case MFMailComposeResultCancelled: break; case MFMailComposeResultSaved: break; case MFMailComposeResultSent: break; case MFMailComposeResultFailed: break; default: break; } //Dismiss the mailViewController. [self dismissModalViewControllerAnimated:YES]; } 

Is this what you are looking for? Then you can handle each error or termination separately!

+1
source

All Articles