【发布时间】:2016-12-19 17:13:04
【问题描述】:
我无法从我的应用程序内部在 MFMailComposeViewController 中发送电子邮件。我收到一条日志消息,表明电子邮件已发送,但它从未发送到我的帐户。我必须转到本机邮件应用程序并从发件箱发送。即使在本机应用程序中,也没有错误告诉我它失败的方式。我是否缺少隐私设置或其他内容?这原本工作得很好。我在 iOS 10 更新后遇到了这个问题。
-(void)sendEmail:(NSString*)email order:(NSMutableArray *)orderA{
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
if ([MFMailComposeViewController canSendMail])
{
mail.mailComposeDelegate = self;
[mail setSubject:[NSString stringWithFormat:@"Order #%@ order", storeNum]];
[mail setMessageBody:[orderA description] isHTML:NO];
[mail setToRecipients:@[email]];
[self presentViewController:mail animated:YES completion:nil];
}
else
{
NSLog(@"This device cannot send email");
}
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result) {
case MFMailComposeResultSent:
NSLog(@"You sent the email.");
break;
case MFMailComposeResultSaved:
NSLog(@"You saved a draft of this email");
break;
case MFMailComposeResultCancelled:
NSLog(@"You cancelled sending this email.");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail failed: An error occurred when trying to compose this email");
break;
default:
NSLog(@"An error occurred when trying to compose this email");
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
【问题讨论】:
标签: objective-c mfmailcomposeviewcontroller