我正在通过 MFMailComposeViewController 发送 pdf。在 Outlook 中查看时,发件人的签名被视为附件,但在 iOS 本机邮件应用程序中则不然。其他一切都按预期工作。
签名显示附件的原因是什么?
@IBAction func sendSpecSheetWithEmailButton(_ sender: subclassedUIButton) {
buttonURL = sender.urlString!
specName = sender.specSheetName!
let fileURL = URL(string: buttonURL)
if fileURL == URL(string: "https://www.example.com") {
alertUserSpecNotAvailable(fileURL: fileURL!, specName: specName)
} else {
sendMail(fileURL: fileURL!, attachmentType: "pdf", to: [""], cc: ["[email protected] /cdn-cgi/l/email-protection"], subject: "Spec Sheet", message: "The spec sheet you requested is attached. \n\nSent via Our iPhone app")
}
}
几年前就有人在这里问过类似的问题,但一直没有明确的答案。
编辑:这里是sendMail()
func sendMail (fileURL: URL, attachmentType: String, to: [String]?, cc: [String], subject: String, message: String) {
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setSubject(subject)
mail.setToRecipients(to)
mail.setCcRecipients(cc)
mail.setMessageBody(message, isHTML: false)
switch attachmentType {
case "pdf":
if let fileData = NSData(contentsOf: fileURL as URL) {
print("File data loaded.")
mail.addAttachmentData( fileData as Data, mimeType: "application/pdf", fileName: specName)
}
return self.present(mail, animated: true, completion: nil)
case "url":
mail.setMessageBody("The requested spec sheet is can be found here: \(fileURL)", isHTML: true)
return self.present(mail, animated: true, completion: nil)
case "none":
return self.present(mail, animated: true, completion: nil)
default: break
}
} else {
self.showSendMailErrorAlert()
}
}