When I send an e-mail with a PDF attachment from an iOS device, the PDF attachment doesn't get displayed properly in the Outlook mail client. Here is how it looks like:
(The attachment PDF is actually sent, if you right click the e-mail and select 'View Attachments', then you will be able to view the PDF. However, with the red cross the customers think that the attachment wasn't properly attached.)
Here is the code that sends the e-mail:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setToRecipients:#[#"test#test.com"]];
[controller setSubject:#"Subject"];
[controller setMessageBody:emailData.emailBody isHTML:YES];
[controller addAttachmentData:emailData.reportData mimeType:#"application/pdf" fileName:emailData.reportName];
[self presentViewController:controller animated:YES completion:nil];
There is a workaround: If you set the message body as not HTML ([setMessageBody:isHTML:]), then the attachment is correctly displayed in Outlook. However, this means that you can't properly format the e-mail text and also can't add any kind of HTML signature to the e-mail.
This problem occurs with iOS7; I can't remember too well but I think the attachments were fine in iOS6.
Is it possible to have the e-mail HTML formatted and have the PDF attachment looking good in Outlook? Is the problem at the e-mail creation part or more at the Outlook side? The other e-mail clients (Gmail or Yahoo) seem to be handling this well.
We were working on the same issue and our team spent all day on this one today. One thing that we discovered today is that if the PDF only has one page, it will cause the the error. However, when we added a second blank page to the PDF, then the PDF came through properly as an attachment.
It looks like Outlook is trying to display a single page PDF inline rather than as an attachment. If you add the second page, it worked fine.
Hope that helps.
Did you got reason why PDF attach as in-line instead normal attachment in email?
Know When Mac OS X Mail Will Show a PDF Inline, When as an Icon
To know whether Mac OS X Mail will display a PDF file attachment as an icon or inline, look at the file's length:
PDF files of only one page are displayed inline in the message text.
PDF files with two or more pages are shown as icons.
For the single-page PDF files, you can switch between inline and icon display by selecting View as Icon or View in Place from the context menu respectively. To open the context menu, click on the PDF (shown inline or as an icon) with the right mouse button, click with the left mouse button while holding down Ctrl or tap with two fingers on the trackpad while the mouse cursor is over the PDF.
The following works for me:
// Should octet-stream be more specific for a PDF file?
// YES: It seems that earlier (was this iOS6 or iOS7, before iOS7.1?) that the PDF icon showed up properly with just the #"application/octet-stream" and the fileName having .pdf. However, just now (3/30/14), with iOS7, the PDF icon only showed up when I changed the MIME type to #"application/pdf"
[email addAttachmentData:data
mimeType:#"application/pdf" // #"application/octet-stream"
fileName:justFileName];
Check this http://email.about.com/od/macosxmailtips/qt/et080506.htm
PDF files of only one page are displayed inline in the message text.
PDF files with two or more pages are shown as icons.
I've been working the same problem myself and I've been having all sorts of problems (blog post to my users at https://easybooksapp.com/blog/media-types-for-pdf-attachments).
For most people it's fine, the PDF appears in their mail client fine. But for some mail clients such as Outlook and when viewing Gmail in Chrome I see the same error you're seeing. The attached PDF appears as a broken image, despite the attached file being sent as the correct MIME type (application/pdf). I narrowed this down to a problem in how the Mail app on iOS encodes the attachment when the user has an HTML signature set in their iOS Mail settings. If their signature includes an embedded image (the image data is included in the message) this causes the problem. When users delete their signature and replace it with a plain text or simple html signature it's all fine!
Today I was about to start working on finding out the differences between how OS X and iOS send the mail, as under OS X the mail is received okay. I just repeated the same tests today to discover the problem seems to have gone away in iOS 7.1. To confirm it I've repeated the exact same steps on an older iPad that still has iOS 7.0 and the problem exists as before.
So it looks like it was in fact an iOS problem in the end.
CORRECTION:
I've updated the iPad from iOS 7.0 to 7.1 and the problem still exists. I will have to do some more work to find out what the difference in encoding is between OS X and iOS 7.
Use text/pdf instead of application/pdf.
Related
I show pdf with webview but, when pdf shows application goes to back and browser shows pdf url. I do not want to application goes to background. Is this possible to open and view pdf document on Smartface?
I tried this;
this.WebView1.openLinkInside = true;
this.WebView1.URL = "http://adadasd.com/adsad.pdf";
it will be supported version 4.3 gonna be released 2nd week of Feb.
You can check the roadmap.
http://www.smartface.io/roadmap/
General > Blob support
I attach my own document type to mail using addAttachmentData. On iOS6 the MFMailComposeViewController uses a document icon (large_document.png) that I created to represent the attachment. On iOS5 there is just a blank white space where a document icon should be.
[mailComposer addAttachmentData:recipeData mimeType:#"application/developiosapp" fileName:#"<filename>" ];
My Info.plist looks like this:
Many Thanks!
I have an App that displays a PDF in a UIWebView that is stored in the App itself.
All working fine! Until I renamed my App. The App started off being called PDFApp, then I changed it to Micro PDF, and again all worked fine.
the client then changed their minds and wanted it to be called "MIC Flooring", but when i do this the PDF does not load in the UIWebView. Very weird! everything else works as expected. If I changed the named back to Micro PDF then it works fine again.
Does anyone know why this may be happening?
Thanks
Sam
I found that you cannot have a space in your Project name - this was making the App not work properly.
instead change the Project Name to be something like - "MyAppName"
and change the 'Bundle display name' in the plist
our app loads profile pages from our website INSIDE the app. They have been optimized for iPhone css, but they are still an html page. Our mailto link isnt working as expected.
When clicked, nothing happens. However, when clicked and held (tap and hold), the menu slides up with "new message", "create new contact", "copy", etc.
How should this be formatted to get the Mail.app to automatically launch?
<a class="action_bubble" target="_blank" rel="external" href="mailto:bob#bob.com">Send Email</a>
The "call" link works as expected.
<a class="action_bubble" href="tel:1234567890">Call</a>
So, not sure what to do with this...
Here is a project on GitHub that addresses your issue. Basically, when you use a UIWebView controller, you need to decide how to manage the links using the delegate handler for UIWebView. In Interface Builder you can have it automatically recognize phone numbers which is probably why your phone numbers work and it will recognize http links as default behavior. However, mailto and some of the other special href options will need to be handled manually.
make sure "Detection" property is set for your UIWebView like "Phone","Address". you can set it from your IB.
or from code
self.webView.dataDetectorTypes = UIDataDetectorTypeAll;
Could it be, that you have just tried within the simulator? The simulator does not have a mail app, so it couldn't be opened. Try on a device. I think your code actually works.
I've just tested on a device: your code works.
A little late to the party but I've found out the following:
iOS has some weird ways to deal with web content
DON'T encapsulate your email address within an A tag, just put it there as plain text
Make sure that in your storyboard (if using one) the webView has the Addresses property checked and you're done ... same goes for phone numbers
I am loading an HTML in my UIWebView. Now I want a user to allow editing this HTML if he wants. Basically it is an email functionality and my body is in HTML format so I render it a UIWebView which works fine. Now if a user wants to reply to this mail, I would like to give him the ability to edit the HTML formatted body. I read something about HTML 5 content editable property but that doesn't seem to help. How can I accomplish it using UIWebView? I have seen the native iphone mail client implementing this functionality.
If there is no other way and I am forced to use MFMailComposeViewController, can I use MFMailCompose View controller to send mails to my own server or for that matter any server?
You can edit the format of the document in a UIWebView through Javascript using the method:
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;
For example to change the body background do:
[_webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('body').style.backgroundColor='#FFFFFF'"];
Using MFMailComposeViewController should be the easiest solution to your problem. As for the To: address, simply set the view controller's recipients using - (void)setToRecipients:(NSArray*)toRecipients.