3
我試圖R內發送一封電子郵件,2個附件,其中之一是一個圖片,我想顯示嵌入式電子郵件內嵌圖像R
我可以成功地與兩個附件發送電子郵件,但我卡在內嵌顯示中。
任何想法,將不勝感激
當前代碼:
setwd(<filepath>)
library(sendmailR)
library(png)
##### SET BASIC EMAIL CHARACTERISTICS
from <- "[email protected]"
to <- "[email protected]"
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'包代替 - 看看[示例](https://github.com/rpremraj/mailR)。或者對你的圖像進行base64編碼,並將其放在''內。 – lukeA
@lukeA感謝您的快速回復!兩個問題:1.如果我使用mailR軟件包,它會將我的整個電子郵件轉換爲HTML,並且附件必須以html格式,而不是.xlsx格式。這是否準確? 2.如果我使用選項,那仍然是HTML嗎? – Krby
1.不是和2.是。 – lukeA