Load UIWebView's Contents into Email Message

1.4k views Asked by At

I have a UIWebView in my view controller. This UIWebView shows a PDF file. I have created a button. When the user clicks on this button, I want to send the content of the UIWebView via email. As a template I use the MailComposer from Apple. In this template Apple isn't using a UIWebView. Apple uses local stored data which works fine. So I am looking to send the content of the UIWebView, my displayed PDF, but I don't know how to do this.

Thanks.

2

There are 2 answers

4
Alexsander Akers On BEST ANSWER

You could try using -stringByEvaluatingJavaScriptFromString: to get the HTML content of the page and using -setMessageBody:isHTML: to set the message body. You may want use a <base /> tag, though, to set the page's base URL so relative URLs function.

Edit

You could download the PDF and use addAttachmentData:mimeType:fileName: to attach the PDF to an email.

0
ader On

What you will need to do is download the pdf and save it on the device and then attach it as per Apple' example.

see one approach to downloading here