MFMailComposeViewController在图像附件前面生成空行

时间:2013-03-12 08:39:38

标签: iphone outlook email-attachments mfmailcomposeviewcontroller

我使用MFMailComposeViewController在iPhone上创建eMails。这些邮件包括文本,文本附件和一些图像附件。

if ([MFMailComposeViewController canSendMail]) {

    mailController = [[MFMailComposeViewController alloc] init];
    [mailController setToRecipients:recipients];
    if ([ccRecipients count] > 0) [mailController setCcRecipients:ccRecipients];
    [mailController setSubject:project];
    [mailController setMessageBody:message isHTML:NO];

    if (csv) {
        [mailController addAttachmentData:csvData mimeType:@"text/csv" fileName:csvFileName]; 
    }

    QEMailAddPicturesOperation * operation = [[QEMailAddPicturesOperation alloc] init];
    operation.delegate = self;
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    [queue addOperation:operation];
}

@implementation QEMailAddPicturesOperation

- (void) main {
    ....
    for (NSString * fileName in listOfPictures) {
        NSString * path = [directory stringByAppendingPathComponent:fileName];
        NSData * imageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:path], PIC_COMPRESSION_RATE );
        [mailController addAttachmentData:imageData mimeType:@"image/jpg" fileName:fileName];
    }
}

一切正常,我可以发邮件。 但结果是:

Content-Type: multipart/mixed; boundary=Apple-Mail-256A861D-10BB-4031-8DFB-0E8FDA8F9337

....

Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (1.0)
X-Mailer: iPhone Mail (9A405)

....

--Apple-Mail-256A861D-10BB-4031-8DFB-0E8FDA8F9337
Content-Transfer-Encoding: 7BIT
Content-Type: TEXT/plain;
charset=us-ascii





--Apple-Mail-256A861D-10BB-4031-8DFB-0E8FDA8F9337
Content-Disposition: inline;
filename=MFA_001.JPG
Content-Type: IMAGE/jpg;

....

您会看到:邮件编辑器在附加的(和base64编码的)图像之间放置了几条文本行。

Outlook 2010将这些行解释为附件(ATT ......)。例如,发送8个图像会在Outlook中创建8个附加但空的附件。 Outlook还将iPhone-Mail的签名显示为附件。 Mac上的Outlook 2011可以运行。

如何避免在iPhone上创建空行或在Outlook(2007年,2010年)中创建附件?

1 个答案:

答案 0 :(得分:0)

我在这里转发了这个问题 - MFMailComposeViewController Attaches Signature as .txt file,因为没有答案。

经过多次挖掘,这是交换服务器的问题,而不是Swift / iOS /等问题。它与Exchange预期订购电子邮件内容的方式有关。如果新版本的Exchange解决了这个问题,我还没有找到明确的答案。麻省理工学院的链接特别提到了Exchange Server 2007&此外,我能够确认问题是Exchange发送邮件的时间,但未收到。

http://kb.mit.edu/confluence/pages/viewpage.action?pageId=4981187

https://support.microsoft.com/en-us/help/969854/the-body-of-a-message-is-shown-incorrectly-as-an-attachment-if-you-try