我是R编程的新手,我做了一个小项目来向R的世界介绍我自己,我想做的是帮助我的一位同事自动完成他每周做的手动电子邮件处理。
这封电子邮件包括一个图表,在excel,道琼斯指数价格,我们公司的股价,和一些评论,他手动更新每周。
我已经知道如何使用RDCOMClient包发送电子邮件,但我想做的是整合到电子邮件的正文(如果可能的话,以HTML格式),图表和股票价格,他也拉。我希望自动化所有这些,所以他所要做的就是更新评论并运行脚本。
这里的关键限制因素是目标受众,这将是给那些不喜欢打开电子邮件附件的高管们提供的。他们想在手机上打开一封电子邮件,获取相关信息,然后继续前进。
到目前为止,我的程序是这样的:
library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "R Test"
outMail[["body"]] = "Hello"
outMail$Send()发布于 2017-05-24 15:27:41
当然,首先你要保存你的形象。然后使用HTMLbody使用HTML代码插入图像,如下所示:
library(htmlTable)
png("pictest.png")
plot(iris$Sepal.Length)
dev.off()
StockPrice <- "25.25"
MyHTML <- paste0("<html><p>This is a picture.</p>
<img src='C:/Users/iwes/Desktop/RWorkingFolder/pictest.png' >
<p> Our StockPrices is: $", StockPrice,
"<p>here is a table:</p>",
htmlTable(head(iris,5)))
library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "R Test"
outMail[["HTMLbody"]] = MyHTML
outMail$Send()https://stackoverflow.com/questions/44162385
复制相似问题