将gvis对象(存储为HTML的图像)嵌入到mailR-R中的内联中

har*_*. s 6 email smtp sendmail r sendmailr

我正在使用googleVisChart并希望将gvis对象(存储为HTML的图像)嵌入到内联使用mailR包中.

我有以下代码从我的服务器发送邮件 -

library(mailR)
send.mail(from = "admin_xxx@apsmail.xx.xxx.xx",
          to = c("first.second@jba.com"),
          subject = paste("Batch Job Stats on",now),
          body = paste("Dear Sir/Madam,<br><br>

                       Please find below the image",".<br><br>",
                       "<img src=\"D:/xx/Batch_Processing/Batch_Processing_Run/Rplot1.png\">",".<br><br>"
          ),
          html = TRUE,inline = TRUE,         
          smtp = list(host.name = "xxxx01.xxx.xxx.xx"),
          authenticate = FALSE,
          send = TRUE)
Run Code Online (Sandbox Code Playgroud)

上面的代码完全正常 - 我嵌入了一个图像(存在于我的服务器的D盘中)

现在我googleVis用来创建一个图表并将它们存储在html文件中.(出现在我服务器的D盘中)

Gauge <-  gvisGauge(CityPopularity,
options=list(min=0, max=800, greenFrom=500,
greenTo=800, yellowFrom=300, yellowTo=500,
redFrom=0, redTo=300, width=400, height=300))
plot(Gauge)

print(Gauge, tag="chart", file="test1.html")
Run Code Online (Sandbox Code Playgroud)

所以现在我的问题是我无法嵌入我的.html文件(使用上面的代码创建test1.html)来发送电子邮件,其中googleVis包含嵌入在邮件描述主体中的图表图像.(我无法保存gvis对象-Chart as .p​​ng ).我见过解决方案 - 在SO中与此类似,但它并没有帮助我.

omi*_*kes -1

如果您打开“tmp.html”作为文件(即位置为文件://*/tmp.html),则可能会发生安全警告。您需要的是通过 http:// 访问 html。

因此,如果您可以更改任何可访问标签的网站页面(例如博客),您可以通过复制并粘贴 tmp.html 的内容来使用它,类似于:

http://takahashik.blogspot.com/2011/01/googlevis-example.html

这是著名的“iris”形式的案例:

http://takahashik.blogspot.com/2011/01/googlevis-case for-information iris_10.html

另外,如果您有网络服务器,您可以通过在服务器上传输 tmp.html 来使用它。