Ios MFMailComposeViewController正在内联PDF,使其在windows上无法读取
出于某种原因,我的转发电子邮件的应用程序正在生成一个附件,而该附件不会显示在Outlook中 如果附加单个PDF,则PDF将以内联方式显示在mail composer窗口中,而不是作为附件。发送时生成的电子邮件在Outlook中无法查看(附件为红色X),但在Mac Mail中可以正常查看 如果我附加了多个PDF,它看起来是正常的,PDF不是内联的,而是像您预期的那样出现在mac/windows上 我没有做任何奇怪的事情,这段代码非常简单。关于为什么单个PDF不会作为附件而不是内联附件附加到电子邮件中,有什么想法吗Ios MFMailComposeViewController正在内联PDF,使其在windows上无法读取,ios,objective-c,email,mfmailcomposeviewcontroller,Ios,Objective C,Email,Mfmailcomposeviewcontroller,出于某种原因,我的转发电子邮件的应用程序正在生成一个附件,而该附件不会显示在Outlook中 如果附加单个PDF,则PDF将以内联方式显示在mail composer窗口中,而不是作为附件。发送时生成的电子邮件在Outlook中无法查看(附件为红色X),但在Mac Mail中可以正常查看 如果我附加了多个PDF,它看起来是正常的,PDF不是内联的,而是像您预期的那样出现在mac/windows上 我没有做任何奇怪的事情,这段代码非常简单。关于为什么单个PDF不会作为附件而不是内联附件附加到电子邮
-(void)startNewEmailTo:(NSArray*)recipients ccList:(NSArray*)ccList withSubject:(NSString*)subject withBody:(NSString*)body withAttachments:(NSSet*)attachments
{
MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init];
mailVC.mailComposeDelegate = self;
[mailVC setSubject:subject];
[mailVC setToRecipients:recipients];
if (ccList != nil)
[mailVC setCcRecipients:ccList];
for (EmailAttachment* attachment in attachments)
{
// Get attachment data
NSString *localFilePath = attachment.fileStatus.localFilePath;
NSData *attachmentData = [NSData dataWithContentsOfFile:localFilePath];
// Find the MIME type of the file
NSString* fullPath = [localFilePath stringByExpandingTildeInPath];
NSURL* fileUrl = [NSURL fileURLWithPath:fullPath];
NSURLRequest* fileUrlRequest = [NSURLRequest requestWithURL:fileUrl];
NSError* error = nil;
NSURLResponse* response = nil;
[NSURLConnection sendSynchronousRequest:fileUrlRequest returningResponse:&response error:&error];
NSString *attachmentMimeType = [response MIMEType];
// If the mimetype is still unknown just try binary/octet-stream
if (!attachmentMimeType)
attachmentMimeType = @"binary/octet-stream";
// Add the attachment
[mailVC addAttachmentData:attachmentData mimeType:attachmentMimeType fileName:[attachment displayName]];
}
[mailVC setMessageBody:body isHTML:YES];
[self presentViewController:mailVC animated:YES completion:^(void)
{
}];
}
编辑我发现只有在iPad上,当邮件合成窗口位于弹出窗口中时,才会发生这种情况。如果我在iphone上尝试此功能,该附件将显示为正常附件并正常工作。我发现这是UIKit中的一个错误。我已经能够用一个示例应用程序重现这个问题。这种情况只发生在iPad上,即通过HTML电子邮件发送单个PDF附件时 我已经向苹果公司提交了一个bug,但不知道他们是否/何时会解决它。如果这个问题影响到你,请提交一个bug,当他们发现更多的人提交它时,也许它会得到解决 作为记录,这个问题是在iOS 7.1.2上遇到的。我不知道这之前是否是一个问题,但这是截至发帖时的最新版本