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
恢复收件人电子邮件地址?