这让我发疯了。该应用程序创建一个PDF,当PDF只有一页时,它就可以很好地附加到电子邮件中。但是,如果PDF不止一页,则该文件将不会附加到电子邮件中。
更多信息:
任何人都知道有任何错误或有人遇到此问题吗?
以下是代码块:
//Setup Email
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
[composer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail])
{
[composer setToRecipients:[NSArray arrayWithObjects:EmailTO.text, nil]];
[composer setCcRecipients:[NSArray arrayWithObjects:EmailCompany.text, nil]];
[composer setSubject:[NSString stringWithFormat:@"PDF From: %@", EmailCompanyName.text]];
[composer setMessageBody:EmailBody.text isHTML:NO];
//Attach PDF
NSString *myAttachment = [NSString stringWithFormat:@"%@", showReportName.text];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *myFile = [documentsPath stringByAppendingPathComponent:myAttachment];
NSData *myData = [NSData dataWithContentsOfFile:myFile];
[composer addAttachmentData:myData mimeType:@"application/pdf" fileName:myAttachment];
[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:composer animated:YES];
[composer release];
} else
[composer release];