我有一个应用程序使用MFMailComposeViewController
通过电子邮件发送文档。我在某处阅读我需要启用至少一封电子邮件,以便方法[MFMailComposeViewController canSendEmail]
将返回YES并通过电子邮件发送文档。然而,只要我点击电子邮件按钮,它所做的就是返回到前一个视图。使用MFMailComposeViewController无法在应用程序中发送电子邮件
我查了代码,[MFMailComposeViewController canSendEmail]
返回NO。谁能告诉我为什么会发生这种情况?
下面是代码:
- (void)sendEmail
{
if ([MFMailComposeViewController canSendMail] == NO) return;
NSURL *fileURL = document.fileURL; NSString *fileName = document.fileName;
NSData *attachment = [NSData dataWithContentsOfURL:fileURL options:(NSDataReadingMapped|NSDataReadingUncached) error:nil];
if (attachment != nil)
{
MFMailComposeViewController *mailComposer = [MFMailComposeViewController new];
[mailComposer addAttachmentData:attachment mimeType:@"application/pdf" fileName:fileName];
[mailComposer setSubject:fileName];
mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
mailComposer.modalPresentationStyle = UIModalPresentationFormSheet;
mailComposer.mailComposeDelegate = self;
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];
}
}
喜的委托方法!一旦我尝试了这个,我会尽快回复你。感谢您的回应! :) – 2012-08-08 14:20:09
这一个工程。谢谢! – 2012-08-09 02:51:56
提示信息应该是“为了邮件,请在设置中配置您的电子邮件帐户。” – 2015-08-13 07:45:24