开发者

Using MFMailComposeViewController to send both HTML and Plain Text versions of email

How can I use MFMailComp开发者_如何学运维oseViewController to send both an HTML and fallback plain text version of an email? The API has a method for setting the message body as either/or, but not a way to specify both. I have seen other apps do it (such as Doodle Jump), so it must be possible.


After considerable investigation, both in code and using Google, I've come to the conclusion that it is not possible to do this via MFMailComposeViewController. I would love someone to prove me wrong, so if you discover otherwise, I'll be happy to vote your answer up.


I can only provide guesses as I've not tried this.

The documentation says that calls to setMessageBody:isHTML: replace the previous body. Its worth trying two calls - one with isHTML:YES and one with NO, just in case the docs are flakey: but that's pretty unlikely.

If the boundary is constant (I'm hoping it is) I'd say the way to do it would be to send it as HTML and fake the plain text part to the end. You will need to send yourself a HTML email or 3 and check that the boundary is constant, and grab it. Then append

------=_NextPart_111_2222_11223344.aabbccdd
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Plain text content

replacing the NextPart stuff with the real boundary. If boundary is not consistent, then I have no idea :-) Worth a try maybe ?


This is what i am doing, the output is fine, i am not able to attach the image, else i would hv shown you guys

 NSString *emailBody = @"<HTML><BODY><B>It is raining in sunny California!</B><table><tr><td>row1</td><td>row2</td></tr><tr><td>row3</td><td><b>row4</b></td></tr></table></BODY></HTML>";
    [picker setMessageBody:emailBody isHTML:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜