我正在使用以下代码发送电子邮件
library(RDCOMClient)
library(openxlsx)
library(xtable)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "ex@example.com"
outMail[["subject"]] = paste0("Report ", Sys.Date() - 1)
wb <- createWorkbook()
addWorksheet(wb, "S1")
writeDataTable(wb, "S1", x = head(iris))
saveWorkbook(wb, tf <- tempfile(fileext = "xlsx"))
df <- read.xlsx(tf)
df_html <- print(xtable(df), type="html", print.results=FALSE)
outMail[["Attachments"]]$Add(tf)
outMail[["HTMLBody"]] = sprintf('
Hello world, here is the table:
%s
Merry Christmas & a happy New Year!
', df_html) # add your html message content here
outMail$Send()
唯一的区别是我想将工作簿中的单元格区域(已保存)作为图片粘贴到电子邮件正文中。该怎么办?