MFMailComposeViewController canSendMail returns YES but does not send mail in iOS

Below is my code for sending attachments in the mail. It works great. I can send letters, but I do not always receive letters.

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; // Set the subject of email [picker setSubject:@"My data file"]; // Add email addresses [picker setToRecipients:[NSArray arrayWithObjects:emailId, nil]]; // Fill out the email body text NSString *emailBody = @"Hello, \n Please find the data from the iOS app in the attachments.\n\n Thank you.\nMy Team."; // This is not an HTML formatted email [picker setMessageBody:emailBody isHTML:NO]; // Create NSData object from file NSData *exportFileData = [NSData dataWithContentsOfFile:filePath]; // Attach image data to the email [picker addAttachmentData:exportFileData mimeType:@"text/csv" fileName: [self.CSVNameTextField text]]; // Show email view if ([MFMailComposeViewController canSendMail]) { [self presentModalViewController:picker animated:YES]; } 
+4
source share
3 answers

After sending Mail with your application, go to Mail-Software on your iPhone, you will most likely find mail in the Outbox folder.

The reason MFMailComposeViewController simply redirects Mail to Mail-Software, and it doesn't care what happens next to the message. So it’s up to your Mail-Software how and when the Outbox will be updated.

+6
source

I had the same problem, I found that she would go through the mailbox and say that she sent, and then nothing worked.

After about 20-30 minutes, the first one passed, and then gradually all the others that I sent also passed.

I don’t know why it takes so long if I find out that I’ll edit this answer, but be sure to wait up to an hour before assuming your code is broken.

Hope this helps someone who, like me, could spend their code again and again

+2
source

In my case, I had to manually open the iphone email application, then emails were immediately sent and received.

+1
source

All Articles