views:

513

answers:

2

I'd like to send a text outline via email using MFMailComposeViewController. I'm currently doing this by creating a HTML version of the document and setting this as the body of the message.This works fine when viewing the email in MFMailComposeViewController, but on the receiving end (MobileMail.app, GMail Webinterface, OSX Mail.app) the formatting is lost.

This is my current code:

- (IBAction)showMailController {
if (![MFMailComposeViewController canSendMail]) return;
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate = self;

NSString *stringRepresentation = @"<html><head></head><body><ul><li>@grocery</li><ul><li>Milk</li><li>Cat food</li><li>Rice</li><li>Tofu</li></ul></ul></body></html>";
[mailComposeViewController setMessageBody:stringRepresentation isHTML:YES];

[self presentModalViewController:mailComposeViewController animated:YES];
[mailComposeViewController release];

}

Am I doing something wrong? Is there an other way to do it?

I also tried exporting as simple text outline with manually indenting (I inserted two spaces as tab didn't work), but text editors don't recognize this as an outline.

    NSMutableString *inset = [[NSMutableString alloc] init];
NSUInteger i;
for (i=0; i<insetCount;i++) {
 [inset appendString:@"  "];
}


NSMutableString *string = [[NSMutableString alloc] initWithString: [NSString stringWithFormat:@"%@%C ", inset, 0x2022]];

Thank you for your help!

+1  A: 

In my apps, I only put what is in between the body tags, i.e. NO

html    
head
body

tags. Just put the stuff you would normally put in between the body tags and it should work.

coneybeare
I already tried this but it still removes the formatting. It's interesting that other formatting styles (<b> or <i>) work fine.
Markus Müller
Just a short update: I wrote a radar for this issue. So far Apple hasn't responded to it.
Markus Müller
A: 

I'm having the same issue. I have have a single line text string in the body with no CRLF but when I receive the mail it has CRLF inserted at seemingly random places.

Hope there is an answer for this because I really need to be able to deliver perfectly formatted email.

James Wheeler