views:

474

answers:

3

Hello - I am having a problem with sending csv attachments via MFMailComposeViewController. Sometimes they come through just fine, but for other users they don't come through as attachments, but rather as text inline in the email (with <br/> instead of line returns.) It's very strange. Anybody know what I'm doing wrong? Here is a snippet of my code:

MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate = self;

NSString *csv = @"foo,bar,blah,hello";
NSData *csvData = [csv dataUsingEncoding:NSUTF8StringEncoding];
[mailComposeViewController addAttachmentData:csvData mimeType:@"text/csv" fileName:@"testing.csv"];

[mailComposeViewController setSubject:@"testing sending csv attachment"];
[mailComposeViewController setMessageBody:@"csv file should be attached" isHTML:NO];
[self presentModalViewController:mailComposeViewController animated:YES];
A: 

I believe the second parameter to setMessageBody:isHTML: must be YES for attachments to not show up inline.

Frank Schmitt
A: 

Even if you set isHTML param to YES, your message body can be sent as plain/text if the message body can be represented as such. And attachments in plain/text messages are not always recognized correctly by some email clients (Outlook).

In my case adding a link in the message body helped. Formatting text as bold with HTML tags works too. Tricky!

Tested on iPod 1G 3.1.3.

komorian
A: 

I have a similar issue with image attachment... That's really annoying because the image I want to attach should be downloaded once received by the user. But integrated in the body of the email (at a smaller size than it should be) make it not the best way to download.

Any ideas? Someone? :(

Pierre-Jean Quilleré