Emailing single page pdf file as an attachment fro

2020-06-18 09:15发布

In my ios app user can send the pdf file as an attachment to some other. It was working on pre ios 7 devices. After upgraded to ios 7 the attachment was missing when app presents the ios mail interface.

Here the code i used to set the mime type:

[mailComposer addAttachmentData:pdfData mimeType:@"application/octet-stream" fileName:fileName];

The above mime type works great on pre ios 7 but on ios 7 it was not taking my file as an attachment. So, i changed the mime type like this:

[mailComposer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName];

It was working fine on ios 7 and pre ios 7 devices but the problem was,On iPad if the attached pdf file has single page then it treated as inline image instead of an attachment. This is happening onnly on iPad on iPhone its fine. Also if i send that mail to some one, On the recipient side also it shows like an inline image when they open that mail on iphone or ipad. since when they tap it it allows two option 1. save image 2. cancel. Also this issue not about ios 7 ipad devices this is happening on all ipad devices which was running under ios 5, ios 6, ios 6.1 and ios 7. Any idea how to resolve it?. What mime type should i use for this to resolve it?.

Note:- for more info please check the attached screenshotenter image description here

-loganathan

标签: ios ipad
3条回答
该账号已被封号
2楼-- · 2020-06-18 09:49

I have same problem with single page PDF. Just change mimeType to text/pdf instead of application/pdf and it's works.No further change required.

[objMailComposer addAttachmentData:myData mimeType:@"text/pdf" fileName:@"myapp.pdf"];
查看更多
该账号已被封号
3楼-- · 2020-06-18 10:04

I sometimes have the same issue with mail.app on OSX and have compressed the file into a zip file as a workaround. Perhaps that is an option?

查看更多
小情绪 Triste *
4楼-- · 2020-06-18 10:08

Use plain text message body, the pdf will shows as normal file attachment.

[mailController setMessageBody:body isHTML:NO];
查看更多
登录 后发表回答