I have a script that is scheduled to run multiple times on a daily basis and is automated through TaskScheduler. Inside this script is a chunk of code to send an email when the process is completed.
When I run the script manually (without using TaskScheduler) the email gets eventually sent, through this code that is at the bottom of the script:
OutApp <- COMCreate("Outlook.Application")
## create an email
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = paste ("xxx@xxx.com",
"xxx@xxx.com",
sep = ";", collapse = NULL)
outMail[["subject"]] = "Some text"
outMail[["body"]] = "Some text"
## send it
outMail$Send()
But when exactly the same script runs through TS, I got this error in the log:
Error in COMCreate(guid, existing = FALSE) : Failed to create COM object: Server execution failed Calls: COMCreate -> getCOMInstance -> COMCreate Execution halted
It looks like TS is blocking the send - any workaround?