我在代码中制作了一个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];
}