如何在iphone SDK中发送电子邮件?任何从iphone获取电子邮件地址的示例教程 也?
答案 0 :(得分:17)
您应该使用隐藏在MessageUI框架中的MFMailComposeViewController
类和MFMailComposeViewControllerDelegate
协议。
首先发送消息:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
然后用户完成工作并及时获得委托回调:
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error;
{
if (result == MFMailComposeResultSent) {
NSLog(@"It's away!");
}
[self dismissModalViewControllerAnimated:YES];
}