Skip to content

Instantly share code, notes, and snippets.

@daattali
Last active March 30, 2018 00:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daattali/df4d2dbb0eb7199ac138 to your computer and use it in GitHub Desktop.
Save daattali/df4d2dbb0eb7199ac138 to your computer and use it in GitHub Desktop.
Send a text message via email from R
library(shiny)
library(gmailr)
ui <- fluidPage(
textInput("subj", "Subject", "Schedule change"),
textInput("text", "Message"),
actionButton("btn", "Send")
)
server <- function(input, output, session) {
observeEvent(input$btn, {
test_email <- mime() %>%
to(c("youremail@gmail.com", "anotheremail@gmail.com")) %>%
html_body(input$text) %>%
subject(input$subj)
# attach_file("file.txt")
test_email <- sub("Content-Disposition: inline\r\n--","Content-Disposition: inline\r\n\r\n--", as.character(test_email))
ret_val <- send_message(test_email)
})
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment