Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone MessageUI email attachments not being sent to receiver
    primarykey
    data
    text
    <p>I am trying to attach an image and a pdf to an email using the MessageUI framework. I followed the <a href="http://developer.apple.com/iphone/library/samplecode/MailComposer/index.html#//apple_ref/doc/uid/DTS40008865" rel="nofollow noreferrer">MailComposer</a> example in the Apple documentation. </p> <p>On the iPhone it seems to work perfectly, the image and the pdf both show up in the body of the send mail window as expected.</p> <p>However, when I receive the email on my MacBook there are two problems.</p> <p>1) myImage.png shows up as an attachment and is the correct dimensions but is totally blank</p> <p>2) myPDF.pdf doesn't show up as an attachment at all</p> <p>But, when I receive the mail on my iPhone, myImage.png shows up fine. myPDF.pdf still doesn't show up in mail on my iPhone though.</p> <p>Hope someone can shed some light on what might be happening.</p> <p>Here is the relevant code:</p> <pre><code>MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Test Email"]; // Attach an image to the email NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"png"]; NSData *imageData = [NSData dataWithContentsOfFile:imagePath]; [picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"myImage"]; // Attach a PDF file to the email NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"myPDF" ofType:@"pdf"]; NSData *pdfData = [NSData dataWithContentsOfFile:pdfPath]; [picker addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"myPDF"]; // Fill out the email body text NSString *emailBody = @"This is a test."; [picker setMessageBody:emailBody isHTML:NO]; [self presentModalViewController:picker animated:YES]; [picker release]; </code></pre> <p><b>EDIT</b> Instead of saving and retrieving my image and PDF to my mainBundle I used NSDocumentsDirectory and everything worked fine.</p>
    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.
    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