在应用程序中发送电子邮件?

时间:2013-06-25 03:40:39

标签: ios email mfmailcomposeviewcontroller

我是xcode的新手,我想知道如何在应用中发送电子邮件!我的代码如下,但我一直收到“self presentModalViewController”行的错误。我的代码完全错了吗?或者我只是忘记声明选择器,我如何声明选择器?有人请帮帮我

     MFMailComposeViewController* controller          = [[MFMailComposeViewController alloc]         init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO];
if (controller)[self presentModalViewController:controller animated:YES];


}
- (void)mailComposeController:(MFMailComposeViewController*)controller
  didFinishWithResult:(MFMailComposeResult)result
                error:(NSError*)error;
{
if (result == MFMailComposeResultSent) {
NSLog(@"It's away!");
}
[self dismissModalViewControllerAnimated:YES];
}

1 个答案:

答案 0 :(得分:0)

请使用您的邮件作曲家 [self presentViewController:controller animated:YES];