Created
September 19, 2016 09:31
-
-
Save victor-geere/62d14c91491bd01ea1c41c55c82b79ea to your computer and use it in GitHub Desktop.
R send email
This file contains 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
#https://www.r-bloggers.com/send-emails-with-attachments-from-r-command-line/ | |
#load package | |
library(“sendmailR”) | |
#use string formatting and your system info to format FROM address | |
from <- sprintf(“<Project1@%s>”, Sys.info()[4]) | |
to <- “<example@example.com>” | |
subject <- “Test Email From R” | |
#create list with text of body as first element | |
#second list element is R object to attach using the mime_part() function | |
body <- list(“Email sent from R. Dataframe attached.”,mime_part(data.frame(x=rnorm(1000),y=rnorm(1000)),name=”output”)) | |
sendmail(from, to, subject, body, control=list(smtpServer=”ASPMX.L.GOOGLE.COM”)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment