Skip to content

Instantly share code, notes, and snippets.

@daattali
Last active Mar 30, 2018
Embed
What would you like to do?
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