iOS发送邮件的代码

iOS发送邮件的代码,第1张

概述iOS发送邮件的代码 @H_419_0@下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

@H_419_0@内存溢出小编现在分享给大家,也给大家做个参考。

  1.导入库文件:MessageUI.framework
    - (voID)dIDClickSendEmailbuttonAction{                if ([MFMailComposeVIEwController canSendMail] == YES) {                            MFMailComposeVIEwController *mailVC = [[MFMailComposeVIEwController alloc] init];              //  设置代理(与以往代理不同,不是"delegate",千万不能忘记呀,代理有3步)              mailVC.mailComposeDelegate = self;              //  收件人              NSArray *sendtoperson = @[@"[email protected]"];              [mailVC setToRecipIEnts:sendtoperson];              //  抄送              NSArray *copytoperson = @[@"[email protected]"];              [mailVC setCcRecipIEnts:copytoperson];              //  密送              NSArray *secrettoperson = @[@"[email protected]"];              [mailVC setBccRecipIEnts:secrettoperson];              //  主题              [mailVC setSubject:@"hello world"];              [self presentVIEwController:mailVC animated:YES completion:nil];              [mailVC setMessageBody:@"魑魅魍魉,哈哈呵呵嘿嘿霍霍" isHTML:NO];          }else{                        NSLog(@"此设备不支持邮件发送");                    }            }            - (voID)mailComposeController:(MFMailComposeVIEwController *)controller dIDFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{                switch (result) {              case MFMailComposeResultCancelled:                  NSLog(@"取消发送");                  break;              case MFMailComposeResultFailed:                  NSLog(@"发送失败");                  break;              case MFMailComposeResultSaved:                  NSLog(@"保存草稿文件");                  break;              case MFMailComposeResultSent:                  NSLog(@"发送成功");                  break;              default:                  break;          }                    [self dismissVIEwControllerAnimated:YES completion:nil];      }            //  系统发送,模拟器不支持,要用真机测试      - (voID)dIDClickSendSystemEmailbuttonAction{                NSURL *url = [NSURL URLWithString:@"[email protected]"];          if ([[UIApplication sharedApplication] canopenURL:url] == YES) {                            [[UIApplication sharedApplication] openURL:url];                    }else{                        NSLog(@"此设备不支持");          }            }  

@H_419_0@以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

@H_419_0@ 如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的iOS发送邮件的代码全部内容,希望文章能够帮你解决iOS发送邮件的代码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1106439.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存