ios发邮件 - ios9.3上面使用苹果自带的发邮件类库,发送邮件到企业邮箱结果失败了

 mobiledu2502857697 发布于 2022-10-28 10:58

我用这段代码在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打印一下?

    2022-10-29 16:56 回答
  • 需要设置邮箱账户。

    2022-10-29 16:57 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有