3

我需要通过 Microsoft Outlook 在 R 中发送电子邮件附件。除了发送电子邮件附件的代码行之外,此页面上的所有代码都有效。 通过 Outlook 在 R 中发送电子邮件

对我不起作用的代码行是:

outMail[["Attachments"]]$Add(path_to_attach_file)

有没有人有任何意见或建议?预先感谢您的帮助!

对不起; 我刚刚意识到,在我对您的评论的回复中,很难阅读我的错误消息和代码块。

以下是我收到的错误消息:

checkErrorInfo> 80020009 
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352567
Error: Exception occurred.

这是我运行的整个代码块:

require(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail <- OutApp$CreateItem(0)
outMail[["bcc"]] <- "someone@someemail.com"
outMail[["subject"]] <- "TEST"
outMail[["body"]] <- "This is a TEST"
outMail[["Attachments"]]$Add("A:/Automate_Emails/Test_Attachment.pdf")
outMail$Send()

请注意,我只在运行第二行到最后一行代码时收到错误消息,即:

outMail[["Attachments"]]$Add("A:/Automate_Emails/Test_Attachment.pdf")

非常感谢你的帮助!最好的祝福。

4

1 回答 1

3

您的问题在于您在添加附件时没有逃脱转义

你有以下

 outMail[["Attachments"]]$Add("A:/Automate_Emails/Test_Attachment.pdf")

你应该看起来像这样

 outMail[["Attachments"]]$Add("A:\\Automate_Emails\\Test_Attachment.pdf")
于 2018-04-03T01:03:22.247 回答