我在代码中制作了一个 pdf 文件,并将其作为附件发送到电子邮件地址。当它显示 时MFMailComposeController
,附件在电子邮件中,但我收到的电子邮件中没有附件。这可能是什么原因?我在这里附上了代码。
if(
[MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailViewController=[[MFMailComposeViewController alloc]init];
[mailViewController setSubject:@"Maintenance Request Form"];
mailViewController.mailComposeDelegate=self;
[mailViewController setToRecipients:[NSArray arrayWithObject:@"BRE@appiwork.com"]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *file = [documentsDirectory stringByAppendingFormat:@"/MaintenanceRequest.pdf"];
NSData *data=[NSData dataWithContentsOfFile:file];
[mailViewController addAttachmentData:data mimeType:@"application/pdf" fileName:@"MaintenanceRequest.pdf"];
[self presentViewController:mailViewController animated:YES completion:nil];
}