Skip to content

Instantly share code, notes, and snippets.

@dwhdai
Last active May 31, 2019 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwhdai/a898f13b5d9420382bb76fd0ae827503 to your computer and use it in GitHub Desktop.
Save dwhdai/a898f13b5d9420382bb76fd0ae827503 to your computer and use it in GitHub Desktop.
Sending Outlook email within R
# Install RDCOMClient package
install.packages("RDCOMClient", repos = "http://www.omegahat.net/R")
library(RDCOMClient)
## init com api
OutApp <- COMCreate("Outlook.Application")
## create an email
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = "destination@email"
outMail[["subject"]] = "some subject"
outMail[["body"]] = "some body"
## send it
outMail$Send()
# Send attachments
outMail[["Attachments"]]$Add(path_to_attch_file)
# Change "from" address
outMail[["SentOnBehalfOfName"]] = "yoursecondary@mail.com"
# Reference: https://stackoverflow.com/questions/26811679/sending-email-in-r-via-outlook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment