views:

199

answers:

2

How can I use MFMailComposeViewController 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.

A: 

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 ?

Andiih
That's a reasonable guess, and I had already investigated both approaches. The second call just replaces the message body. The boundary is also generated by the Mail Composer and is not constant, so I can't change that. Thanks for your answer though!
Chris Garrett
Shame - it was worth a try!
Andiih
A: 

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.

Chris Garrett