我想使用MFMailComposeViewController发送邮件。一切工作,除了邮件不发送,我总是得到MFMailComposeResultFailed。MFMailComposeViewController不发送邮件
任何指针?我不使用模拟器,并发送邮件从我的设备工作。我确实有一个连接(通过Reachability进行测试),[MFMailComposeViewController canSendMail]返回YES。
项目,没有崩溃没有编译器警告......
我想使用MFMailComposeViewController发送邮件。一切工作,除了邮件不发送,我总是得到MFMailComposeResultFailed。MFMailComposeViewController不发送邮件
任何指针?我不使用模拟器,并发送邮件从我的设备工作。我确实有一个连接(通过Reachability进行测试),[MFMailComposeViewController canSendMail]返回YES。
项目,没有崩溃没有编译器警告......
这是IOS4中的一个错误。
我的手机上同时拥有Exchange邮件帐户和旧的非活动IMAP帐户。显然,这导致了iOS4的问题。邮件实际上被卡在发件箱中。一旦我删除不活动的IMAP帐户,一切都按预期工作。
这很难说没有看到一个代码片段,但您应检查以下内容:
1)您已正确设置MFMailComposeViewController's
委托并实施其代表方法;
2)你有设置使用setSubject:
3)已设置使用setMessageBody:isHTML:
消息体和任选地设置一个附加使用邮件主体addAttachmentData:mimeType:fileName:
4)您已呈现给用户您的邮件撰写视图控制器使用类似
[self presentModalViewController:mcvc animated:YES];
H这有助于。
是啊,我已经全部正确。原来,这是一个操作系统中的错误。请参阅下面的答案。 无论如何谢谢:) – 2010-08-04 07:11:02
有些读者可能会面临这样的问题:
确保您实现<MFMailComposeViewControllerDelegate>
协议
下面的代码:
// in TestViewController.h
@interface TestViewController : UIViewController<MFMailComposeViewControllerDelegate>
@end
// in TestViewController.m
@interface TestViewController()
@end
@implementation
- (void) compose {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Hello there"];
[picker setToRecipients:@[]];
// Fill out the email body text
NSString *emailBody = @"Hello, sending a message from my app";
[picker setMessageBody:emailBody isHTML:NO];
// use this function. presentModalViewController:... is deprecated
[self presentViewController:picker animated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
看起来像4.1中仍然存在的错误。还不确定4.2。 – 2010-11-05 14:06:42