How can I embeded an interactive chart in an email body

社会主义新天地 提交于 2019-12-12 18:23:07

问题


I am testing dygraphs, what I would like is generate an html file and then send it in an email so outlook can open it and I see the content in the body (NOT just attachment)

This is an extension of this post

Here is dygraphs.Rmd

---
output:
  html_document:
    fig_width: 6
    fig_height: 4
    self_contained: no
---

```{r}
require(dygraphs)
dygraph(nhtemp, main = "New Haven Temperatures", ylab = "Temp (F)") 
```

The following code works and send the email (dygraphs.r)

library(dygraphs)
library(mailR)
library(rmarkdown)

send <- function(subject, body){
  send.mail(from = "me",
            to = "me",
            subject = subject,
            html = T,
            inline = T,
            body = body,
            smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "me", passwd = "pwd", ssl = T),
            authenticate = T,
            send = T)
}

knitr::knit2html(input='dygraphs.Rmd', output='dygraphs_knitr.html',options = "")
rmarkdown::render('dygraphs.Rmd','html_document','dygraphs_rmarkdown.html')
send('dygraphs_knitr', 'dygraphs_knitr.html')
send('dygraphs_rmarkdown', 'dygraphs_rmarkdown.html')

I doing this I receive the email but the graph is not rendered. Is there a workaround (if this is possible)?

来源:https://stackoverflow.com/questions/34694775/how-can-i-embeded-an-interactive-chart-in-an-email-body

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!