小编mec*_*911的帖子

如何在iOS应用程序中发送附件(文件PDF)的电子邮件?

我的应用程序中有按钮,当我打开时,它向我显示带有attachemnt的新电子邮件.我发送电子邮件到我的电子邮件地址后,我有这个消息和附件,但附件包含我的应用程序的最后一个屏幕..我想打开此消息与支持文件的附件.也许你知道我哪里有错误?

- (IBAction)showEmail:(id)sender {

NSString *emailTitle =  @"elllo";

NSString *messageBody = @"Hi ! \n Below I send you ";

NSArray *toRecipents = [NSArray arrayWithObject:@"m1891@gmail.com"];

NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, self.view.bounds, nil);
UIGraphicsBeginPDFPage();

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIGraphicsEndPDFContext();
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];

mc.mailComposeDelegate = self;

[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"MV.pdf"];
[mc setToRecipients:toRecipents];

[self presentViewController:mc animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)

}

objective-c ios mfmailcomposeviewcontroller

1
推荐指数
1
解决办法
4425
查看次数