I'm trying to pass param through pipes and then send the data thru email. My code crash when I click send mail button. I'm not sure how to solve this question as I relatively new in R language.
library(shiny)
library(gmailr)
suppressPackageStartupMessages(library(gmailr))
library(shinyAce)
gm_auth_configure(path = "credentials.json")
ui <- fluidPage(
pageWithSidebar(
headerPanel("Email sender"),
sidebarPanel(
textInput("from", "From:", value="from@gmail.com"),
textInput("to", "To:", value="to@gmail.com"),
textInput("subject", "Subject:", value=""),
actionButton("send", "Send mail")
),
mainPanel(
textInput(inputId = "message", value="", label=""),
)))
server <- function(input, output, session) {
from <- reactive({input$from})
to <- reactive({input$to})
subject <- reactive({input$subject})
message <- reactive({input$message})
mail <- gm_mime() %>%
gm_from(from) %>%
gm_to(to) %>%
gm_subject(subject) %>%
gm_text_body(message)
observeEvent(input$send, {
gm_send_message(mail)
})
}
shinyApp(ui = ui, server = server)
Here the warning error I got. Thanks in advance.
Warning: Error in as.vector: cannot coerce type 'closure' to vector of type 'character'
87: as.character.default
85: gregexpr
84: substitute_regex
83: quoted_printable_encode
82: as.character.mime
80: lapply
75: as.character.mime
73: gm_send_message
72: observeEventHandler [C:/Users/Desktop/cred/sendemails.R#42]
1: runApp