0

This is my first post to the group so please be kind :)

I am sending a couple of audio attachments from my app as follows:

 MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
 picker.mailComposeDelegate = self;
 picker.modalPresentationStyle = UIModalPresentationCurrentContext;
 [picker setSubject:@"Test message"]; 
 NSArray *toRecipients = [NSArray arrayWithObject:@"foo@bar.com"];
 [picker setToRecipients:toRecipients];

 // multiple attachments are made as follows
  NSData *myData = [NSData dataWithContentsOfFile:filePath];
 [picker addAttachmentData:myData mimeType:@"audio/x-caf" fileName:fileName];

 [picker setMessageBody:@"test message" isHTML:NO];

 [controller presentModalViewController:picker animated:YES];

A mailComposeController method takes care of dismissing the modal view.

Unfortunately, when the message is delivered the mime headers for the attachments land up having the Content-Id set to null. Here is what it looks like:

 Content-Type: audio/x-caf; name="audio_1.caf"
 Content-Transfer-Encoding: base64
 Content-Id: <(null)>
 Content-Disposition: attachment; filename="audio_1.caf"

If I manually delete the Content-Id field and reload the message in my Mac Mail program (Mail Version 3.6) the attachments show up correctly. In other words, I don't really need/want theContent-Id to be inserted in the mime header.

Also, its worth mentioning that for debugging purposes if I set the mime type to "image/jpeg" the mime header does get a valid Content-Id string. All my attachments show up in Mail. As is to be expected, in that case the attachments don't open correctly on the Mac or iPhone.

Any help would be greatly appreciated.

thanks, apurva

Sam
  • 1,509
  • 3
  • 19
  • 28

2 Answers2

0

According to this post, you cannot manually set the Content-ID

How to add a UIImage in MailComposer Sheet of MFMailComposeViewController

Community
  • 1
  • 1
iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
0

OK. Figured it out -- more by accident than anything else.

The null content ids seem to be inserted by the mail server (not my app or MFMailComposeViewController).

Initially I was testing the send with a personal yahoo account. Thats when I ran into the problem. When I switched to my work account the problem disappeared.

thanks, apurva