发送电子邮件后如何从MFMailComposeViewController获取收件人电子邮件

时间:2018-10-26 21:16:14

标签: ios swift mfmailcomposeviewcontroller

SWIFT(4或更高)。

我只有一个操作(按钮),可以触发MailViewController(let mc: MFMailComposeViewController = MFMailComposeViewController()),那时我只有要发送的邮件的标题和正文,但是没有收件人

我已经设置了mailComposeController(见下文)

extension MyViewController: MFMailComposeViewControllerDelegate {

    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
        switch result {
        case .cancelled:
            print("Mail cancelled")
        case .saved:
            print("Mail saved")
        case .sent:
            print("Mail sent to")
        case .failed:
            self.showAlert(title: "Error", message: "Mail was not send due to the following error:\n \(error?.localizedDescription)")
        default:
            break
        }
        self.dismiss(animated: true, completion: nil)
    }
}

我想在发送邮件(.sent)时保存收件人,以便用户可以检查他是否已经发送了电子邮件。

是否可以从mailComposeController恢复收件人电子邮件地址?

0 个答案:

没有答案