4

I've been using the RDCOMClient packge in R for over a year now without a problem.

Now suddenly it's giving me an error:

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

Here is my code (I've cleaned the code due to privacy):

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)

I have few other scripts that I schedule to send emails. One of them uses the blastula package (also sends email through Outlook) and I have no problem there.

Any idea why I'm getting this error?

Viðar Ingason
  • 265
  • 3
  • 11

2 Answers2

1

I had a similar problem when trying to use RDCOMClient to print a pdf from a word d. What worked for me was to use the URI for the file location even if it is a local file. So for example: path_to_attachment <- "file:/W:/Rwd/report/report_this_month/report.pdf"

Gakku
  • 337
  • 2
  • 8
0

I came across this error and was clueless for a while, but in my case it ended up being a matter of my attachment filepath being wrong.

If I were you I would try to first comment out the line outMail[["attachments"]]$Add(path_to_attachment) and see if things work as expected.

Ricky
  • 1,005
  • 1
  • 12
  • 15
  • The only reason for the email is the attachment so this is not an option for me. This code has been working just fine for more than a year now and the code has been unchanged the whole time so I'm a bit surpriced. – Viðar Ingason Jan 05 '21 at 09:39
  • I'm not saying to remove the attachment completely, I was just thinking you could confirm the error you are running into is due to the attachment not being found like I suspect. If you just commented out that one line and the e-mail works, you would know it's because your attachment filepath is not found. For example in my case I am using the slashes in the other direction `path_to_attachment <- "W:/Rwd/report/report_this_month/report.pdf"` sounds like your script was running fine before, so probably not that, but just make sure the attachment can be found by the R session – Ricky Jan 05 '21 at 15:05
  • Commenting out the attachment did not solve the problem. Still getting the same error. – Viðar Ingason Jan 25 '21 at 09:09