我修改了答案以添加解决方案的第二部分:
我发现使用 MFMailComposeViewController 发送带有标签的 HTML 电子邮件有两个问题。
1) 对于最终被编码为可引用打印的任何 HTML 正文,您必须放置换行符,以便没有任何行大于 76 个字符。
2) 标记内的文本应包裹在 a 中,以确保 MFMailComposeViewController 不会将内容解释为链接中的链接。
例如,以下 HTML:
<a href='http://link/to/my/site.com'>site.com</a>
正在变成:
<a href='http://link/to/my/site.com'><a href='http://site.com'>site.com</a></a>
通过将我的 HTML 正文更改为:
<a href='http://link/to/my/site.com'><span>site.com</span></a>
电子邮件已正确发送。
一个完整的例子:
NSMutableString *body = [NSMutableString string];
// add HTML before the link here with line breaks (\n)
[body appendString:@"<h1>Hello User!</h1>\n"];
[body appendString:@"<a href=\"http://www.mysite.com/path/to/link\"><span>Click Me!</span></a>\n"];
[body appendString:@"<div>Thanks much!</div>\n"];
干杯!