Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

iphone - MFMailComposeViewController : how do I embed a clickable URL link into the email message body

I want my app using the MFMailComposeViewController to send an email such that the recipient can click on the embedded url to open the corresponding web site. MFMailComposeViewController does not appear to support this explicitly. Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I deleted my previous answer as it was incorrect and irrelevant. After much hair pulling I finally figured out what was going on in my case and is probably what is happening in this question.

When you compose the HTML body for the MFMailComposeViewController you must put line breaks in the HTML. If any line is > 76 chars long, the body will be interpreted as follows:

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

If you put line breaks in, the Content-Transfer-Encoding: quoted-printable will not happen and everything works as expected. Assuming you have proper HTML.

As an example, build the body as follows:

NSMutableString *body = [NSMutableString string];
// add HTML before the link here with line breaks (
)
[body appendString:@"<h1>Hello User!</h1>
"];
[body appendString:@"<a href="http://www.mysite.com/path/to/link">Click Me!</a>
"];
[body appendString:@"<div>Thanks much!</div>
"];

Cheers!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...