【发布时间】:2015-06-19 12:47:03
【问题描述】:
代码:
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Sample Subject"];
[mail setMessageBody:@"Here is some main text in the email!" isHTML:NO];
[mail setToRecipients:@[@""]];
[self presentViewController:mail animated:YES completion:NULL];
} else {
NSLog(@"This device cannot send email");
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result
{
switch (result) {
case MessageComposeResultCancelled:
break;
case MessageComposeResultFailed:
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to send SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
case MessageComposeResultSent:
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
我使用 MFMailComposeViewController 发送邮件。 即使我收到成功消息,收件人也没有收到我的邮件。
我错过了什么?
【问题讨论】:
-
你是在真机上测试吗?或模拟器,因为要检查功能工作,您必须在设备上进行测试。
-
我在设备上测试了它。但接收器没有收到它..
-
你检查你发送的邮件了吗??
-
我查过了。它是空的..
-
代码格式和拼写
标签: ios iphone mfmailcomposeviewcontroller