ios发邮件 - ios9.3上面使用苹果自带的发邮件类库,发送邮件到企业邮箱结果失败了
怪我咯
怪我咯 2017-04-17 17:51:32
0
2
598

我用这段代码在ios8上面能正常发送邮件到企业邮箱,但是到了ios9上面邮件就发送失败了,是不是用在ios9上面发邮件还需要什么设置丫

    MFMailComposeViewController *mailPickerVc = [[MFMailComposeViewController alloc] init];
    mailPickerVc.mailComposeDelegate = self;
    [mailPickerVc setSubject:PROJECT_NAME];//邮件主题
    [mailPickerVc setToRecipients:@[EMAIL_AUTHOR_ADRESS]];//设置收件人
    [mailPickerVc setMessageBody:@"管理驾驶舱 : \n" isHTML:NO];
    UIImage *image = _cutScreenBgView.saveImage;
    NSData *imageData = UIImagePNGRepresentation(image);
    [mailPickerVc addAttachmentData:imageData mimeType:@"" fileName:@"管理驾驶舱.png"];
    [self presentViewController:mailPickerVc animated:YES completion:nil];
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    NSString *message;
    switch (result) {
        case MFMailComposeResultCancelled:message = @"取消编辑邮件";
            break;
        case MFMailComposeResultSaved: message = @"保存邮件";
            break;
        case MFMailComposeResultSent:message = @"发送邮件";
            break;
        case MFMailComposeResultFailed:message = @"保存邮件/发送邮件失败";
            break;
        default:
            break;
    }
    [UIAlertView showMsgWithTitle:@"发邮件" msg:message confirm:@"确定" cancel:nil blocks:^(NSInteger index) {
        if (index == 0) {//确定
            [TAPublicUtilitiy judjeIsTimeOutSessionAndUpdateActivieSessionTimeCompletion:^(BOOL isShow) {
                if (isShow) {
                    //展示登录页面
                    [self presentViewController:[TAPublicUtilitiy showLoginVc] animated:NO completion:nil];
                } else {
                    [_cutScreenBgView removeFromSuperview];
                    _cutScreenBgView = nil;
                    [self dismissViewControllerAnimated:YES completion:nil];
                }
            }];
        }
    }];
}
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(2)
迷茫

需要设置邮箱账户。

刘奇

能否把- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(nullable NSError *)
的error打印一下?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!