I'd like to open the standard email programm (Outlook) with prefilled values. It is traight forward to define recipients, subject, and body via mailto, yet manypostspointout that it is not possible to add an attachment by this logik. While therearemanysuggestions, I have failed to acheive this via JS or HTML. I cannot use R packages like mailR
etc. since the server does not allow for it.
Any specfic hints how it can be acheived that, as soon as somebody clicks on the button, an email with an attached file, defined by a local path, opens? Any help is much appreciated!
library(shiny)
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
uiOutput("mail")
# If the user could specify the file by himself
# ,HTML('<td><input id="filefield" type="file" name="file" size="24"></td>')
),
mainPanel(),
position = "left"
)
)
)
server <- shinyServer(function(input, output) {
observe({
mail_address <- "mrx@gmail.com"
cc_recipients <- "mrsx@g.mail"
bcc_recipients <- "mr.x@googlr.com"
subject <- "My Report"
text <- "See attachment"
attachment_file <- "myfile.txt"
output$mail <-
renderUI({
a(actionButton(inputId = "email1", label = "Send Mail",
icon = icon("envelope", lib = "font-awesome")),
href = paste0("mailto:", mail_address,
"?cc=", cc_recipients,
"&bcc=", bcc_recipients,
"&body=", text,
"&subject=", subject,
"&attachments=", attachment_file))
}
)
})
})
shinyApp(ui, server)