4

我已经在 R 中使用 RDCOMClient 包一年多了,现在没有问题。

现在突然它给了我一个错误:

<checkErrorInfo> 80070057 
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147024809
Error: The parameter is incorrect.

这是我的代码(由于隐私,我已经清理了代码):

library(RDCOMClient)
library(lubridate)


rmarkdown::render("/report.Rmd", encoding = "UTF-8")

OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)


text <- paste("Attached is the report")
path_to_attachment <- "W:\\Rwd\\report\\report_this_month\\report.pdf"



outMail[["to"]] = "user@xyz.is"
outMail[["subject"]] = "Monthly report"
outMail[["htmlbody"]] = text
outMail[["attachments"]]$Add(path_to_attachment)

outMail$Send()

rm(OutApp, outMail)

我计划发送电子邮件的其他脚本很少。其中一个使用 blastula 包(也通过 Outlook 发送电子邮件),我没有问题。

知道为什么我会收到此错误吗?

4

1 回答 1

0

我遇到了这个错误并且有一段时间一无所知,但在我的情况下,它最终是我的附件文件路径错误的问题。

如果我是你,我会尝试先注释掉该行outMail[["attachments"]]$Add(path_to_attachment),看看事情是否按预期工作。

于 2021-01-05T06:07:35.313 回答