MFMailComposeViewController 发邮件

原创
2013/07/31 16:52
阅读数 928
AI总结
#pragma mark - feedback

- (void)sendFeedBackMail{    
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setSubject:@"subjbect"];
    picker.navigationBar.tintColor = [UIColor colorWithRed:kScreenR/255.0
                                                     green:kScreenG/255.0
                                                      blue:kScreenB/255.0
                                                     alpha:0.5];
    NSArray *toRecipients = [NSArray arrayWithObject:@"xx@xx.com"];
    [picker setToRecipients:toRecipients];
    NSString *emailBody = [NSString
                           stringWithFormat:@"SystemVersion: %@ \n AppVersion: %@ \n 反馈信息:\n",                                           [[UIDevice currentDevice] systemVersion],
                           [[[NSBundle mainBundle] infoDictionary]
                            objectForKey:@"CFBundleShortVersionString"]];
    [picker setMessageBody:emailBody isHTML:NO];
    [self presentModalViewController:picker animated:NO];
}

#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{
    NSString *title = @"邮件发送提醒";
    NSString *msg;
    switch (result){
        case MFMailComposeResultCancelled:
            msg = @"邮件已被取消";
            break;
        case MFMailComposeResultSaved:
            msg = @"邮件保存成功";
            [self alertWithTitle:title msg:msg];
            break;
        case MFMailComposeResultSent:
            msg = @"邮件发送成功";
            [self alertWithTitle:title msg:msg];
            break;
        case MFMailComposeResultFailed:
            msg =@"邮件发送失败";
            [self alertWithTitle:title msg:msg];
            break; 
       }  
    
    [self dismissModalViewControllerAnimated:YES];
    
}

- (void) alertWithTitle: (NSString *)_title_ msg: (NSString *)msg{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_title_
                                                    message:msg
                                                   delegate:nil
                                          cancelButtonTitle:@"好"
                                          otherButtonTitles:nil];
    [alert show];
}
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
AI总结
返回顶部
顶部