I am creating an email in MFMaiilComposeViewController and if I simply create some html snippets and assign them to the message body - all is well. The resulting email (in GMail and Yahoo) looks like the original HTML I sent.
[mailMan_ setMessageBody:body isHTML:YES];
On the other hand, if I also include an XML attachment, my email reader renders everything as plain text … including, the XML inlined. IE: my mail client (GMail, Yahoo) shows the raw HTHML and XML tags - including html tags that I didn't supply - ie: the html, head, body tags the iPhone provides around the content:
NSData *opmlData = [[NSData alloc] initWithData:[opml dataUsingEncoding:NSUTF8StringEncoding]];
NSString *fileName = [NSString stringWithFormat:@"%f.opml", [NSDate timeIntervalSinceReferenceDate]];
[mailMan_ addAttachmentData:opmlData mimeType:@"text/xml" fileName:fileName];
I pop3'd the mails to see what was happening and found that WITHOUT an attachment, the resulting html section of the email contains this block:
--0-1682099714-1273329398=:59784
Content-Type: text/html; charset=us-ascii
<html><body bgcolor="#FFFFFF"><div><h2 style="b
while on the other hand, WITH the XML attachment, the iPhone is sending this:
--0-881105825-1273328091=:50337
Content-Type: text/plain; charset=us-ascii
<html><body bgcolor="#FFFFFF"><div><h2 style="bac
Notice the difference? Look at the Content-Type … text/html vs text/plain. It looks like when I include an XML attachment, the iPhone is errantly tagging the HTML version of the body as plain text! Just to clarify, technically, both with and without the attachment, the iPhone also includes this:
--0-881105825-1273328091=:50337
Content-Type: text/plain; charset=us-ascii
Notebook
Carpentry
Bathroom floor tile
Bathroom wall tile
Scrape thinset
But this obviously isn't where the problem lies.
Am I doing something wrong? What must I do to actually "attach" XML without the iPhone labeling the entire HTML body as plain text. I tried reversing the assignments (attachment first and then body) but no luck.
For what it's worth, the email looks perfect from the iPhone's sending interface. Indeed, the HTML renders correctly and the attachment looks like a little icon at the bottom of the message. This problem has more to do with what the iPhone is actually sending.