我制作了一张带照片的相机应用程序,一旦拍完照片,我就会点击一个uibutton,用该图像作为附件撰写邮件。在编写电子邮件时,即使附件中的图像文件也可以看到,一切似乎都能正常工作。当点按“发送”并打开我的电子邮件ID时,我没有收到任何新的收件箱。这是代码
func sendEmail() {
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients([email])
composeVC.setSubject("Hello!")
composeVC.setMessageBody("Hello this is my message body!", isHTML: false)
let imageData: NSData = UIImagePNGRepresentation(pickedImage.image!)! as NSData
composeVC.addAttachmentData(imageData as Data, mimeType: "image/jpeg", fileName: name)
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
}
func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWith result: MFMailComposeResult, error: Error?) {
controller.dismiss(animated: true, completion: nil)
}
答案 0 :(得分:1)
我发现了这个问题&这是因为我不允许我的iOS设备上的邮件应用程序访问“移动数据”。因此,请不要忘记允许该访问,因为您的设备将通过您登录的苹果ID发送邮件。