无法通过R中的DT包将HTML发送到邮件

时间:2016-03-25 02:49:31

标签: r r-markdown dt

我有一个由DT包创建的HTML文件,使用以下代码:

saveWidget(report_temp, 'report.html')

但我无法通过以下代码将其发送到电子邮件:

`

library(mailR)
sender <- "SENDER@gmail.com"
recipients <- c("RECIPIENT@gmail.com")
send.mail(from = sender,
          to = recipients,
          subject = "Subject of the email",
          body = "report.html",
          smtp = list(host.name = "smtp.gmail.com", port = 465, 
                      user.name = "YOURUSERNAME@gmail.com",            
                      passwd = "YOURPASSWORD", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)

`

收件人只会收到包含源代码的电子邮件。

enter image description here

但如果我使用Rmarkdow创建HTML文件然后将其发送到电子邮件,则电子邮件将显示所有HTML内容(不是源代码)。

enter image description here

我不想使用Rmarkdown因为我想创建带颜色的桌子,... 请帮助,谢谢。

1 个答案:

答案 0 :(得分:0)

尝试添加

html=TRUE

中的

send.mail(