Load UIWebView's Contents into Email Message - iphone

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.

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.

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

Related

InAppSettingsKit UIWebView

How do you add a UIWebView (to load a live site, not an HTML page) to show as a sub-view of IASK?
I see this example in the sample app, but it is using a static local page.
Just put the http:// URL of the page into the File key instead of your local file name.

Opening HTML form attachments in iOS5

I have received an email on my iPhone (with iOS 5.0.1) with an HTML attachment. The HTML attachment contains a form to fill out and submit. The problem is that submitting the form does not work. I click the Submit button and I get switched Safari, but the form information is not posted. Instead, the URL indicated by the form gets requested as via the GET method.
Is the problem that the Quick Look viewer is simply a passive viewer that does not do forms? I'd like to be able to open the attachment in Safari instead, but that does not appear to be an option. If a tap and hold the attachment, the only options I get are Quick Look and Dropbox.
Thanks!
After much research I've decided it simply does not work. Probably by design as a sort of security feature. I discovered a similar problem with Android phones.

Copy string from UIWebView

I've put UIWebView in my app which loads login page, after user logs in, can I write some function that will copy specific link from that UIWebView that is specific for every user?
The best way to do this would probably be to include a JavaScript function in the page that returns the link or data you need. See [UIWebView stringByEvaluatingJavaScriptFromString:]
Another way could be to retrieve the HTML in your iOS code, get the data you need, and then set that content in the UIWebView using the loadHTMLString:baseURL: method.

iPhone - Send contents of webview as mail

I'm composing my messages using images, text and audio files and finally showing the preview in Webview. Now, I want to send what ever it is showing in web view as mail. Even images and audio files must be sent so that end user has just to see the message with all images and aduio files as in original message.
Is it possible?
Send the actual HTML of the web page. Be sure to set the in the page, so any links in the page will be referenced relative to the original URL. There are upsides and downsides to this method:
UPSIDE: Small file will be sent - just the HTML of the base page
DOWNSIDE: Any images and sounds will not be sent in the message - and will have to be downloaded by the users email client from the original URL when the page is viewed. (Any web client that supports HTML content type will be able to do this.)
Don't forget to set the content (MIME) type of the email message to TEXT/HTML.

Just can't seem to fetch the mobile Gmail html, what is wrong?

I'm trying to cache the mobile Gmail webpage because UIWebView does not cache the content itself (mobile safari does, but not UIWebView).
I tried the methods listed here Reading HTML content from a UIWebView basically saving the html either directly from URLRequest or from UIWebView itself. When I try to put the html saved back into UIWebView it is not the same page!
This is the page that I want to save
alt text http://img39.imageshack.us/img39/5679/screenshot20090830at123.png
This is the page that the html saved will display
alt text http://img39.imageshack.us/img39/8734/screenshot20090830at122.png
If you're loading using loadData:MIMEType:textEncodingName:baseURL: make sure you're setting baseURL correctly - that way, the WebView will know where to look for relative stylesheets and so on.
Edit: For example, if I was saving this page, I'd set the base URL to Just can't seem to fetch the mobile Gmail html, what is wrong?.
That looks like the same page to me, but with different stylesheets attached. If you're just re-displaying identical HTML from your local server, the relative stylesheet paths in Google's HTML would no longer be correct. Also, any AJAX requests meant to run after the page loads would no longer work (both because the relative paths to the scripts would be wrong, and also because Cross-Site Scripting restrictions would prevent them from contacting Google).
Attempting to scrape content from an AJAX-enabled application is no small undertaking. You'd have to replicate a lot of GMail's functionality to truly reproduce the exact page Google presents.