The trick is properly escaping the text. All spaces, question marks, ampersands, etc. must be escaped in the embedded URL so it's not confused as part of the mailto URL.
There is a method on NSString that makes this trivial. I'm deliberately going to make you search the docs for it
First off, there is no need to manually put the %20 in the original body string. %20 is what space characters get replaced with. 20 is the hex value for the ASCII value of a space character.
Add an NSLog statement and print out utfEncoded and post that result here.
What do you see in the email after Mail.app is launched?
I think it might actually be working. Is it supposed to make the link a hyperlink? Should I be able to click where it says Google and go to google or should it just say the link.
Currently the body says everything it is supposed to but the google link does not open google.
Whether a URL appears as a link or not is up to the mail application. In one of my apps I generate an email and send it via the Mail.app. Links do appear in the body of the email as expected but my email body is in HTML and the links are using standard <a href="">text</a> type markup.
I did notice that a URL in my signature does not appear as a link. So my guess is that a URL does not normally appear as a link when composing a text email. And this is fine for what you are doing. Most likely the receiver of the email will see the URL as a link when the receive the email.
It's the same as a text email except the body is HTML markup instead of plain text.
Rick... "body is HTML" sounds easy but I get nothing after it hits the <a href="">text</a> tag. Everything that follows that tag is lost, but the email is accepted by mail.app so formatting is not completely out in left field.
in a more readable format ("readable" and HTML might not be compatible!) The string prior to encoding looks like: (carriage returns added to assist readability and there is no To: filled in, that's an exercise for the user)
Code:
@"mailto:?&subject=Test&body=
<Content-Type: Text/HTML>
<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"><body><body>
textForTesting<a href=\"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=123456789&amp;mt=8\" title=\"testTitle\">testing</a>\ntrailingTextToSeeWhatHappens
</body>
</html>"
The resulting email indicates that it is still "Text/plain", so I'm wondering if you might share how you tell mail that it needs to deal with the incoming data as HTML?
Pretty please? With sugar on top?
Thanks
__________________
"Hardware will break. Software comes broken" Unknown Calc-12E <-- ditch your old calculator. CPR•Choking <-- Review your training, just in case. (Free) All of Nature NW <-- scrolls in x and y, with pinch zoom AND scrollable text to boot. It can be done ('taint easy tho)
Things work well until I include the '?' in the app store URL, and that seems to signal mail that "something else important" follows so I'll have to figure that part out but I do definitely appreciate you sharing your code.
Later!
__________________
"Hardware will break. Software comes broken" Unknown Calc-12E <-- ditch your old calculator. CPR•Choking <-- Review your training, just in case. (Free) All of Nature NW <-- scrolls in x and y, with pinch zoom AND scrollable text to boot. It can be done ('taint easy tho)