我有一台 iPad,它具有创建 pdf 并作为电子邮件附件发送的例程。这一切似乎都与电子邮件编辑器打开显示附加的 pdf 文档一起工作。但是,在 iPad 上进行测试时,收到电子邮件时没有附件。有任何想法吗?
[mailComposer addAttachmentData:data mimeType:@"application/pdf" fileName:@"pdffile.pdf"];
[self presentViewController:mailComposer animated:YES completion:nil];
非常感谢
细节:
pdf 文件被创建并称为 pdffile.pdf。以下是完整的电子邮件例程:
MFMailComposeViewController *mailComposer;
mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setModalPresentationStyle:UIModalPresentationFormSheet];
[mailComposer setSubject:[NSString stringWithFormat: @"i-observe Lesson Observation for: %s", "date"]];
[mailComposer setMessageBody:[NSString stringWithFormat: @"i-observe Lesson Observation for: %s", "name"] isHTML:NO];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *file = [documentsDirectory stringByAppendingFormat:@"pdffile.pdf"];
NSMutableData *data=[NSMutableData dataWithContentsOfFile:file];
[mailComposer addAttachmentData:data mimeType:@"application/pdf" fileName:@"pdffile.pdf"];
[self presentViewController:mailComposer animated:YES completion:nil];