MFMailComposeViewController将签名附加为.txt文件 [英] MFMailComposeViewController Attaches Signature as .txt file

查看:127
本文介绍了MFMailComposeViewController将签名附加为.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过MFMailComposeViewController发送pdf。在Outlook中查看时,发件人的签名被视为附件,而不是iOS本机邮件应用程序。其他所有内容都按预期工作。

I'm sending a pdf through MFMailComposeViewController. The sender's signature is seen as an attachment when viewed in Outlook, but not the iOS native mail app.Everything else works as expected.

签名显示的原因是什么一个附件?

What is the reason the signature is showing an attachment?

@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: ["team@example.com"], subject: "Spec Sheet", message: "The spec sheet you requested is attached. \n\nSent via Our iPhone app")
    }
}

多年前有人问过类似的问题,但从来没有一个明确的答案。

Someone asked a similar question on here years ago, but there was never a clear answer.

编辑:这里是sendMail()

here is 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()
    }
}


推荐答案

经过多次挖掘,这是一个问题交换服务器而不是Swift / iOS /等。它与Exchange期望订购电子邮件内容的方式有关。我没有找到一个明确的答案,如果较新版本的Exchange是否解决了这个问题。麻省理工学院的链接特别提到了Exchange Server 2007&此外,我能够确认问题是邮件是由Exchange发送的,而不是收到的。

After some more digging, this is an issue with the exchange server and not with Swift/ iOS/ etc. It has to do with the way that Exchange expects email content to be ordered. I haven't found a clear answer on if the newer versions of Exchange address the issue. The MIT link specifically mentions Exchange Server 2007 & 2010. Also, I was able to confirm that the issue is when the mail is being sent by Exchange, not received.

http ://kb.mit.edu/confluence/pages/viewpage.action?pageId = 4981187

https:/ /support.microsoft.com/en-us/help/969854/the-body-of-a-message-is-shown-incorrectly-as-an-attachment-if-you-try

这篇关于MFMailComposeViewController将签名附加为.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆