omegahat / RDCOMClient

GNU General Public License v2.0
77 stars 34 forks source link

No support for InterfaceSupportsErrorInfo #28

Closed vidarsumo closed 3 years ago

vidarsumo commented 3 years ago

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?

refpuz commented 3 years ago

I have also encountered this error on a few scripts myself that have worked until very recently. I have narrowed it down to the "HTMLBody" property of the outmail object causing the issue. If you use the plain-text "body" property instead, it works flawlessly. Your post is the only one online that I have found that has this issue as well.

vidarsumo commented 3 years ago

Awesome! This works perfectly :) Thank you so much @refpuz

lucvsbrecht commented 2 years ago

Hello guys, I'm with the same problem than vidarsumo, actually, thats the first discussion about it that I found about it.

I need my email to have paragraphs and the signature, but the thing is, I just can't separete the text on paragraphs. In the line outMail[["htmlbody"]] \n haven't worked for me, so I tried different ways. I separated in different variables the text and tried to bring then back together using writeLines and cat, saving it using capture.output. But when I try to use it in outMail[["htmlbody"]] I have the same error than vidar.

duncantl commented 2 years ago

Have you set the body to plain-text or is it using HTML? If it is HTML, you will have to use markup such as

for paragraph and
for line break. Assembling the text in different ways (cat, capture.output) won't significantly change the content of the resulting text. If you are using plain-text for the body, then you probably need to have a blank line between paragraphs, i.e.,

Paragraph 1 ends with a newline

Paragraph 2 starts after the additional blank line so there are two newlines in a row - one at the end of paragraph 1, and another before paragraph 2.