hi folks,
I have many word documents using email address as the file name, for instance,
username@mail.com.docx
I would like to make a shiny app so that the customers could input their own email address, and get an email send by shiny app with an attached docx file using email address as the file name. Is it possible to do it? Here is what I have so far, but I could not get any feedback from the app, no errors. Similar posts are
but I dont want an email to all addresses, I want an email for each of the address as they have their own attached file. Any suggestion or experience?
library(shiny)
library(mailR)
ui=fluidPage(
titlePanel('feedbacks'),
sidebarPanel(
textInput('email',label='email address'),width = 3,
actionButton('go',label='send me email')
)
)
server <- function(input, output, session) {
observeEvent(input$go,{
withProgress(message = "please wait", {
Sys.sleep(1)
setProgress(0.25, detail = "1 Sec")
Sys.sleep(1)
setProgress(0.5, detail = "2 Sec")
Sys.sleep(1)
setProgress(0.75, detail = "3 Sec")
Sys.sleep(1)
setProgress(1, detail = "4 Sec")
isolate({
fullnames=list.files(path = "/Users/Desktop/test", pattern = ".docx");
reactive({
input$email=gsub(pattern = '\\.docx','',fullnames);
send.mail(from='username@foxmail.com',
to=input$email,
subject='feedbacks',
body=c(' '),
smtp=list(host.name='smtp.qq.com',
port=465,
user.name='username',
passwd='password',
ssl=T),
authenticate = T,
send = T,
attach.files = input$datapath
)
})
})
})
showNotification("message sent", type = "message", duration = 10)
})
}
shinyApp(ui,server)