2016-11-25 1 views
1
[![i=iris 
library(shiny) 
library(mailR) 

ui =fluidPage(

    fluidRow(
    div(id = "login", 
     wellPanel(title = "Mail your report", 
        textInput("to", label = "To:", placeholder = "To:"), 
        textInput("sub","Subject:"), 
        textInput("msg","Message:"), 
        actionButton("mailButton",label = "Send mail") 
     ) 
    ),tableOutput(outputId = "fo") 
    ) 
) 
server = function(input, output, session) { 

    observeEvent(input$mailButton,{ 
    isolate({ 
     send.mail(from = "*****@gmail.com", 
       to = unlist(strsplit(input$to, ";", fixed = TRUE)), 
       subject = input$sub, 
       body = input$msg, 
       smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "****@gmail.com", passwd = "******", ssl = TRUE), 
       authenticate = TRUE, 
       attach.files = "fo",html = TRUE, 
       send = TRUE) 
    }) 
    }) 

    output$fo <- renderTable({ 
    a<- as.data.frame(iris) 
    a$new <- a$Sepal.Length+a$Sepal.Width 
    a 

    }) 
} 
runApp(list(ui=ui,server=server)) ][1]][1] 

Hier, wie wir sehen, dass in Server-Funktion kann ich eine neue Spalte ein $ neuer und gesamte Datenrahmen gespeichert wird wieder berechnet habe zu einem Objekt, also muss ich diesen Datenrahmen als pdf/csv/.html irgendein mögliches Format schicken plz führen Sie auf diesemeMailing Ausgabe in Rshiny :: einen Datenrahmen als pdf/.html von Shinyapps.io Anbringen

+0

Sie sollten den Code als Text bekannt geben, damit andere Benutzer den Code prüfen können. –

+0

@JakeConway Was meinst du mit Text. Der Code ist schon in dieser Form nur – Veerendra

+0

@Veerendra Keine Ausgabe Sir ich habe bereits den Code zusammen mit ihm hochgeladen, und zum Glück habe ich die Lösung auch .so Vielen Dank für Ihre Bewertung –

Antwort

2
i=iris 
library(shiny) 
library(mailR) 

a<- as.data.frame(iris) 
write.csv(a,file="test.csv") 
ui =fluidPage(

    fluidRow(
    div(id = "login", 
     wellPanel(title = "Mail your report", 
        textInput("to", label = "To:", placeholder = "To:"), 
        textInput("sub","Subject:"), 
        textInput("msg","Message:"), 
        actionButton("mailButton",label = "Send mail") 
     ) 
    ),tableOutput(outputId = "fo") 
    ) 
) 
server = function(input, output, session) { 

    observeEvent(input$mailButton,{ 
    isolate({ 
     send.mail(from = "****@gmail.com", 
       to = unlist(strsplit(input$to, ";", fixed = TRUE)), 
       subject = input$sub, 
       body = input$msg, 
       smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "****@gmail.com", passwd = "nbwishes", ssl = TRUE), 
       authenticate = TRUE, 
       attach.files = "test1.csv",html = TRUE, 
       send = TRUE) 
    }) 
    }) 

    output$fo <- renderTable({ 
    a<- as.data.frame(iris) 
    a$new <- a$Sepal.Length+a$Sepal.Width 
    write.csv(a,file="test1.csv") 

    }) 
} 
runApp(list(ui=ui,server=server)) 
+0

Dies ist die Lösung, Totally Working !!!! Stellen Sie sicher, dass das Verzeichnis, in dem Sie arbeiten, ist !! –

Verwandte Themen