MFMailComposeViewController发送邮件的实例

#pragma mark - feedback
02  
03 - (void)sendFeedBackMail{   
04     MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
05     picker.mailComposeDelegate = self;
06     [picker setSubject:@"subjbect"];
07     picker.navigationBar.tintColor = [UIColor colorWithRed:kScreenR/255.0
08                                                      green:kScreenG/255.0
09                                                       blue:kScreenB/255.0
10                                                      alpha:0.5];
11     NSArray *toRecipients = [NSArray arrayWithObject:@"xx@xx.com"];
12     [picker setToRecipients:toRecipients];
13     NSString *emailBody = [NSString
14                            stringWithFormat:@"SystemVersion: %@ \n AppVersion: %@ \n 反馈信息:\n",                                           [[UIDevice currentDevice] systemVersion],
15                            [[[NSBundle mainBundle] infoDictionary]
16                             objectForKey:@"CFBundleShortVersionString"]];
17     [picker setMessageBody:emailBody isHTML:NO];
18     [self presentModalViewController:picker animated:NO];
19 }
20  
21 #pragma mark - MFMailComposeViewControllerDelegate
22 - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{
23     NSString *title = @"邮件发送提醒";
24     NSString *msg;
25     switch (result){
26         case MFMailComposeResultCancelled:
27             msg = @"邮件已被取消";
28             break;
29         case MFMailComposeResultSaved:
30             msg = @"邮件保存成功";
31             [self alertWithTitle:title msg:msg];
32             break;
33         case MFMailComposeResultSent:
34             msg = @"邮件发送成功";
35             [self alertWithTitle:title msg:msg];
36             break;
37         case MFMailComposeResultFailed:
38             msg =@"邮件发送失败";
39             [self alertWithTitle:title msg:msg];
40             break;
41        
42      
43     [self dismissModalViewControllerAnimated:YES];
44      
45 }
46  
47 - (void) alertWithTitle: (NSString *)_title_ msg: (NSString *)msg{
48     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_title_
49                                                     message:msg
50                                                    delegate:nil
51                                           cancelButtonTitle:@"好"
52                                           otherButtonTitles:nil];
53     [alert show];
54 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值