我一直在尝试使用GmailR包在一封电子邮件中发送2张图片(必须在邮件正文中添加这些图片)和2个附件(2个excel文件),但到目前为止我还没能弄清楚。我已经查看了文档中的语法和这个小插图- https://cran.r-project.org/web/packages/gmailr/vignettes/sending_messages.html
基于上面的vignette,我尝试了vignette中提到的东西(附件和图像部分)的组合,在邮件正文中添加两个图像+两个单独的xlsx文件。当我尝试发送一个图像/一个附件(如vignetter中提到的),但无法接收多个图像/附件时,它工作得非常好。
#A. # From above mentioned vignette - (This works) - single attachment
email <- gm_mime() %>%
gm_to('someaddress@somewhere.com') %>%
gm_from("someaddress@somewhere.com") %>%
gm_subject("Cars report") %>%
gm_html_body(
'<h1>A plot of <b>MotorTrend</b> data <i>(1974)</i></h1>
<br><img src="cid:foobar">') %>%
gm_attach_file("mtcars.png", id = "foobar")
#B. (This doesn't work) - more than one attachment?
email <- gm_mime() %>%
gm_to('xy@xy.com') %>%
gm_from("xyz@gmail.com") %>%
gm_subject(paste("Overview of Etc - ",today_date)) %>%
gm_html_body(
'<h1>Total Nos<b>XYZ</b> Region <i>(Year)</i></h1>
<br><img src="cid:foobar"><img src="cid:foobar2">') %>%
gm_attach_file(c("Overview1.jpeg","Overview2.jpeg"
,"file1.xlsx","file2.xlsx"), id = c("foobar1","foobar2"))有没有任何人可以建议的变通办法?如果人们能为我指明正确的方向,我将不胜感激!
发布于 2020-10-30 18:51:20
原来,我们只需要再次输入这些子命令!
email <- gm_mime() %>%
gm_to('xy@xy.com') %>%
gm_from("xyz@gmail.com") %>%
gm_subject(paste("Overview of Etc - ",today_date)) %>%
gm_html_body(
'<h1>Total Nos<b>XYZ</b> Region <i>(Year)</i></h1>
<br><img src="cid:foobar"><img src="cid:foobar2">') %>%
gm_attach_file("Overview1.jpeg", id = c"foobar1") %>%
gm_attach_file("Overview2.jpeg", id = c"foobar2")%>%
gm_attach_file("attach1.xlsx")%>%
gm_attach_file("attach2.xlsx")
gm_send_message(email)https://stackoverflow.com/questions/64572666
复制相似问题