小编Göz*_*Bal的帖子

Swift中出现“请设置邮件帐户以发送电子邮件”错误

我尝试通过我的应用发送电子邮件,但收到一个错误消息

“请设置邮件帐户以发送电子邮件”。

我的代码块在下面。

import MessageUI

@IBAction func emailTapped(_ sender: Any) {   

    let mailComposerVC = MFMailComposeViewController()
    mailComposerVC.mailComposeDelegate = self
    mailComposerVC.setToRecipients(["abc@gmail.com"])
    mailComposerVC.setSubject("Sending you an in-app e-mail...")
    mailComposerVC.setMessageBody("Sending e-mail in-app is not so bad!", isHTML: false)

    if MFMailComposeViewController.canSendMail() {
        self.present(mailComposerVC, animated: true, completion: {() -> Void in })
    }  
}

func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Swift.Error?){
    controller.dismiss(animated: true) { () -> Void in } 
}
Run Code Online (Sandbox Code Playgroud)

email iphone email-integration ios swift

3
推荐指数
1
解决办法
3762
查看次数

标签 统计

email ×1

email-integration ×1

ios ×1

iphone ×1

swift ×1