Issues with PDF Email Attachments on iPhones

We are attempting to email PDF’s as attachments. When emailing to various PC’s using various email clients, there is not a problem. However, we emailed to (5) different people with iPhones and (2) showed the attachment as a “MIME-Attachment” and were unable to open it. (3) showed as a PDF and the user was able to open the PDF just fine.

One of the users who see the attachments as a “MIME-Attachment” opened the same exact email that we sent on their PC using Internet Explorer and their Gmail account. The PDF shows fine there and they forwarded it to their self (same exact gmail account) and then opened the forwarded email on their iPhone and the PDF shows fine. So, it seems they can receive PDF’s as attachments just not if sent from Xojo using our code. Is this an iPhone issue or Xojo issue?

Here is the code:

[code]
oEmail=New EmailMessage
oEmail.BodyHTML = Self.kBodyHTML
oEmail.BodyPlainText = self.kBodyText
oEmail.FromAddress = “xxx.xxx”
oEmail.Subject = “xxxxxx”
oEmail.AddRecipient"xxxxx.xxx"

  oAttachment = new EmailAttachment
  oAttachment.MIMEType = "application/pdf"
  oAttachment.ContentEncoding = "UTF8"
  oAttachment.LoadFromFile(oFileList.Item(i))
  oEmail.Attachments.append oAttachment[/code]

Any help would be greatly appreciated.

Brandon

Did you try looking at the source of what they received to see if the encoding was any different on the ones that worked and ones that didn’t.

You will need a different client to look at the message source.

Also were the iOS versions different? Did the attachment fully download? Sometimes you get the little pie circle filling up that shows the attachment is downloading. If you don’t wait for that to finish it usually doesn’t show until you go back and try again.

Have you considered:

  • Different versions of iOS?
  • Different carriers may have different size restrictions?
  • Did you send the exact same PDF to all of the recipients? Could it be that two of the attachments were just unreadable?

We found the issue. When creating the attachment, you have to specify the MIME Type after the LoadFromFile command! This really should be in the documentation as it can lead to extremely hard to find bugs.

[code]
'This code creates the correct email header
oAttachment.LoadFromFile(oFileList.Item(i))
oAttachment.MIMEType = “application/pdf”

Email Header:

Content-Type: application/pdf; name=“testfile.pdf”;
x-mac-type=“3F3F3F3F”
x-mac-creator=“3F3F3F3F”
Content-transfer-encoding: Base64
Content-disposition: attachment[/code]

[code]
'This code ignores the MIME Type specified and changes it to application/base64
oAttachment.MIMEType = “application/pdf”
oAttachment.LoadFromFile(oFileList.Item(i))

Email Header:

Content-Type: application/base64; name=“testfile.pdf”;
x-mac-type=“3F3F3F3F”
x-mac-creator=“3F3F3F3F”
Content-transfer-encoding: Base64
Content-disposition: attachment[/code]

It is interesting that most email clients recognized the attachment as a PDF even without the MIME Type set correctly. Also, the user who’s iPhone could not recognize the PDF attachment is using an iPhone 6 with IOS 9.1.

Brandon

Any idea what he mime type was set to by the load command? Perhaps that’s the bug.

The LoadFromFile command sets the mime type to application/base64.