gpt4 book ai didi

Swift 3 发送带有附件歧义表达式的电子邮件

转载 作者:行者123 更新时间:2023-11-28 15:28:47 25 4
gpt4 key购买 nike

我正在尝试使用带有以下代码的 MFMailComposeViewControllerDelegate 设置电子邮件 View Controller :

let fileName = "test.csv"

let path = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(fileName)

if MFMailComposeViewController.canSendMail() {
let emailController = MFMailComposeViewController()
emailController.mailComposeDelegate = self
emailController.setToRecipients(["testemail.com"])
emailController.setSubject("Test Email")
emailController.setMessageBody("Test Message", isHTML: false)
emailController.addAttachmentData(NSData(contentsOfURL: path)!, mimeType: "text/csv", fileName: "test.csv")
present(emailController, animated: true, completion: nil)
}

上面在 addAttachmentData 行上抛出一个 error 是,

Type of expression is ambiguous without more context.

我错过了什么吗?

最佳答案

使用两个表达式而不是一个:

    let data = Data(contentsOf: path)!
emailController.addAttachmentData(data, mimeType: "text/csv", fileName: "test.csv")

关于Swift 3 发送带有附件歧义表达式的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44939303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com