這是我的第一篇到組,所以請善待:)MFMailComposeViewController增加空的Content-Id
我送一對夫婦的音頻附件,從我的應用程序如下:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
picker.modalPresentationStyle = UIModalPresentationCurrentContext;
[picker setSubject:@"Test message"];
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[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];
一個mailComposeController方法負責解除模態視圖。
不幸的是,當消息傳遞時,附件的MIME頭部出現,Content-Id被設置爲空。這裏是什麼樣子:
Content-Type: audio/x-caf; name="audio_1.caf"
Content-Transfer-Encoding: base64
Content-Id: <(null)>
Content-Disposition: attachment; filename="audio_1.caf"
如果我手動刪除內容ID字段,在我的Mac郵件程序(郵件3.6版)的附件正確顯示加載消息。換句話說,我並不需要/希望將內容Id插入到MIME頭文件中。
另外值得一提的是,出於調試的目的,如果我將MIME類型設置爲「image/jpeg」,MIME頭文件將獲得有效的Content-Id字符串。我的所有附件都顯示在Mail中。正如預料的那樣,在這種情況下,附件在Mac或iPhone上無法正常打開。
任何幫助將不勝感激。
感謝, apurva