// XXXViewController
var controller: MFMailComposeViewController?
func feedback() {
if MFMailComposeViewController.canSendMail(){
controller = MFMailComposeViewController()
//设置代理
controller?.mailComposeDelegate = self
//设置主题
controller?.setSubject("Feedback")
//设置收件人
controller?.setToRecipients(["lancexianghui@gmail.com"])
//设置抄送人
controller?.setCcRecipients([])
//设置密送人
controller?.setBccRecipients([])
//设置邮件正文内容(支持html)
controller?.setMessageBody("Please type here your issue or question:", isHTML: false)
present(controller!, animated: true, completion: nil)
} else {
// 用户未建立邮箱账号,只有建立了邮箱账号才可发送邮件
MessageManager.share.showMessage(theme: .warning, title: "Can't send mail on your device", body: "Please setup an email account on the device.")
}
}
// 代理 - 关闭邮件页面
extension XXXViewController: MFMailComposeViewControllerDelegate {
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
}
网友评论