omegahat / RDCOMClient

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

Irregular Error on $Send #18

Open aleckrance opened 5 years ago

aleckrance commented 5 years ago

I am looking to send a regular report through my work computer in outlook.

I am receiving the error below when calling Email$Send() irregularly. Sometimes my email will send, sometimes it wont. Any help on this would be appreciated.

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

All solutions I found relating to this error occur after attaching a file. I am not having any issue with attaching the file. Below you will find what the console returns after attaching the file.

An object of class "COMIDispatch" Slot "ref": <pointer: 0x0000000002704ca8>

Below is my edited code

library("RDCOMClient")
OutApp <- COMCreate("Outlook.Application")

Outlook <- COMCreate("Outlook.Application")

# Create a new message
Email = Outlook$CreateItem(0)

# Set the recipient, subject, and body
Email[["to"]] = "sm@company.com, po@company.com"
Email[["cc"]] = "myself@company.com"
Email[["bcc"]] = ""
Email[["subject"]] = "Wip Report"
Email[["body"]] = "Hi all,

        Please find attached the WIP Report."
Email[["attachments"]]$Add("C:\\Users\\first_last\\Desktop\\Last, First\\R Folder\\WIP Report\\WIP_dashboard.html")
# Send the message
Email$Send()

# Close Outlook, clear the message
rm(Outlook, Email)