Skip to content

Instantly share code, notes, and snippets.

@victor-geere
Created September 19, 2016 09:31
Show Gist options
  • Save victor-geere/62d14c91491bd01ea1c41c55c82b79ea to your computer and use it in GitHub Desktop.
Save victor-geere/62d14c91491bd01ea1c41c55c82b79ea to your computer and use it in GitHub Desktop.
R send email
#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