Last active
May 31, 2019 14:42
-
-
Save dwhdai/a898f13b5d9420382bb76fd0ae827503 to your computer and use it in GitHub Desktop.
Sending Outlook email within R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"]] = "[email protected]" | |
# 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