Code:
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Sample Subject"];
[mail setMessageBody:@"Here is some main text in the email!" isHTML:NO];
[mail setToRecipients:@[@""]];
[self presentViewController:mail animated:YES completion:NULL];
} else {
NSLog(@"This device cannot send email");
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result
{
switch (result) {
case MessageComposeResultCancelled:
break;
case MessageComposeResultFailed:
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to send SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
case MessageComposeResultSent:
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
I use MFMailComposeViewController to send mail. Even if I get success message my mail is not received by receiver.
What am I missing?
Errrr, really ?
You haven't set a "To" email address, and you're complaining that the email hasn't arrived..?
Try this: hard-code an email address, use "arrayWithObject", and see if the email gets sent now: