Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is MFMailComposeViewController returning MFMailComposeResultFailed?
    primarykey
    data
    text
    <p>I'm facing a strange issue in my app and I need your help !<br> I am using a MFMailComposeViewController to send emails with attachment data. The attachment is either a PDF, a CSV or a XLS file. A ZIP file can also be added to the mail.</p> <p>Everything works fine in most cases but sometimes (actually quite often), when the attachment is a XLS and a ZIP is added, I receive multiple memory warnings and the composer returns MFMailComposeResultFailed, with an error that doesn't help at all (only saying code error 1, "The operation couldn’t be completed. (MFMailComposeErrorDomain error 1.)").</p> <p>My question is why does it do that ? I assume the memory warnings are telling me something is not well managed but I can't figure out what...</p> <p>Here is my code for sending the email</p> <pre><code>-(void) sendMail { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; [self prepareMailPicker:picker]; NSString *filePath = [self getFilePath:pType]; NSString *zipFile = [self getZipPath]; NSString *mimeType; int userPhoto = [User getCSVPhoto]; switch (pType) { case EPDF: mimeType = @"application/pdf"; userPhoto = [User getPDFPhoto]; break; case ECSV: mimeType = @"text/csv"; break; case EExcel: mimeType = @"application/vnd.ms-excel"; break; default: break; } NSData *attachmentData = [NSData dataWithContentsOfFile:filePath]; [picker addAttachmentData:attachmentData mimeType:mimeType fileName:[filePath lastPathComponent]]; if (userPhoto == 1 &amp;&amp; shouldAddZip) { NSData *zipData = [NSData dataWithContentsOfFile:zipFile]; [picker addAttachmentData:zipData mimeType:@"application/zip" fileName:[zipFile lastPathComponent]]; } shouldAddZip = NO; [self presentModalViewController:picker animated:YES]; } -(void) prepareMailPicker:(MFMailComposeViewController*)picker { picker.mailComposeDelegate = (id&lt;MFMailComposeViewControllerDelegate&gt;)self; picker.navigationBar.tintColor = grayDark; [picker setSubject:[TextManager textForKey:@"EMAIL_SUBJECT"]]; NSString *email = [[User currentUser] getEmail]; if (email &amp;&amp; ![email isEqualToString:@""]) [picker setToRecipients:[NSArray arrayWithObject:email]]; NSString *emailBody = [TextManager textForKey:@"EMAIL_TEXT"]; [picker setMessageBody:emailBody isHTML:YES]; } </code></pre> <p>Any help would be grately apreciated !</p> <p>EDIT: as asked by @matt, here is a log to prove that nothing is set to nil :</p> <pre><code>filePath : /var/mobile/Applications/A57F5CD2-E3FE-4417-8810-D746A22CF434/Documents/iNdF_Export_2012-11-19.xls zipFile : /var/mobile/Applications/A57F5CD2-E3FE-4417-8810-D746A22CF434/Documents/iNdF_recus_2012-11-19.zip attachmentData : (NSConcreteData *) &lt;0x1d9c3c20&gt; 53 874 bytes zipData : (NSConcreteData *) &lt;0x1f989100&gt; 6 838 456 bytes </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload