我正在尝试使用R发送一封带有两个附件的电子邮件,其中一个是我想要嵌入式显示的图片。
我可以成功地发送带有两个附件的电子邮件,但在嵌入式显示方面卡住了。
非常感谢您的任何想法。
当前代码:
setwd(<filepath>)
library(sendmailR)
library(png)
##### SET BASIC EMAIL CHARACTERISTICS
from <- "me@gmail.com"
to <- "them@gmail.com"
subject <- "Sales report"
##### PREPARE ATTACHMENT
# put the body and the mime_part in a list for msg
# x = needs full path if not in working directory
# name = same as attachmentPath if using working directory
attachmentObject <- mime_part(x="spreadsheet.xlsx",name="spreadsheet.xlsx")
attachmentObject2 <- mime_part(x="graph.png",name="graph.png")
body <- c("Generic body text", <graph attachmentObject2>)
bodyWithAttachment <- list(body,attachmentObject,attachmentObject2)
##### SEND EMAIL
sendmail(from=from,
to=to,
subject=subject,
msg=bodyWithAttachment,
control=list(smtpServer="<server name>")
)
mailR
包,查看示例。或者将您的图片进行 base64 编码,并将其放置在<img src="...">
中。 - lukeA