4

I am using R to build an automated process to run a SQL query, put the result in an Excel file, and then email the file via Outlook to a customer. I am using RDCOMClient with R4.0. Every time I run the script a warning message in Outlook pops up and tells me a program is trying to send an email and asks me to Allow or Deny the email. I would like to disable this warning message so the script runs automatically, without my intervention.

Because I am using a work machine, I don't seem to have access to disable this warning using options within Outlook, but the following pages seem to suggest that there exists a command using a COM client to disable this warning message.

https://www.add-in-express.com/outlook-security/index.php

Disable warning about a program trying to send an email

Is there any command that I can add to the below general code structure to disable this warning?

library (RDCOMClient)

# Open Outlook
Outlook <- COMCreate("Outlook.Application")

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

# Set the recipient, subject, and body
Email[["SentOnBehalfOfName"]] = "email1@domain.com"
Email[["to"]] = paste("email2@domain.com", sep=";", collapse=NULL)
Email[["cc"]] = ""
Email[["bcc"]] = ""
Email[["subject"]] = "Subject"
Email[["body"]] = "Body"
Email[["attachments"]]$Add("C:\\Attachment.xlsx")

# Send the message
Email$Send()

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

0 Answers0