#import <MessageUI/MessageUI.h>
@interface ThirdViewController : UIViewController<MFMailComposeViewControllerDelegate,GADBannerViewDelegate>
//发送问题报告 email
-(IBAction)sendQuestion:(id)sender
{
MFMailComposeViewController * mailViewController =[[MFMailComposeViewController alloc]init];
mailViewController.mailComposeDelegate =self;
[mailViewController setSubject:@"問題報告"];
[mailViewController setToRecipients:[NSArray arrayWithObject:@"houkoku3@pazu.biz"]];
if ([MFMailComposeViewController canSendMail]) {
[self presentViewController:mailViewController animated:YES completion:nil] ;
}
}
实现委托方法
#pragma mark - MFMailComposeViewControllerDelegate
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
NSString *msg;
switch (result)
{
case MFMailComposeResultCancelled:
msg = @"。。。。";
break;
case MFMailComposeResultSaved:
msg = @"。。。。";
[self alertWithTitle:nil msg:msg];
break;
case MFMailComposeResultSent:
msg = @"。。。。";
[self alertWithTitle:nil msg:msg];
break;
case MFMailComposeResultFailed:
msg = @"。。。。";
[self alertWithTitle:nil msg:msg];
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void) alertWithTitle: (NSString *)_title_ msg: (NSString *)msg
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_title_
message:msg
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
<MessageUI/MessageUI.h>发送邮件
最新推荐文章于 2018-08-24 17:22:27 发布