如何使用 GmailR 包发送多个附件和图像(在邮件中)正文?

How to send multiple attachments and images(in mail) body using GmailR package?

我一直在尝试使用 GmailR 包在一封电子邮件中发送 2 张图片(必须将它们添加到邮件正文中)和 2 个附件(2 excel 文件),但我无法发送弄清楚到目前为止。 我已经看过文档中的语法和这个小插图 - https://cran.r-project.org/web/packages/gmailr/vignettes/sending_messages.html

基于上面的小插图,我尝试结合小插图(附件和图像部分)中提到的内容在邮件正文中添加两个图像 + 两个单独的 xlsx 文件。 当我尝试发送一个 image/one 附件(如小插图中所述)但未能接收多个 image/attachment.

时,它工作得很好
#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"))

是否有任何人可以建议的解决方法?如果有人能指出正确的方向,我将不胜感激!

事实证明,我们只需要再次通过管道输入子命令!

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)