GmailR在电子邮件正文中发送data.frame

时间:2018-05-15 09:10:54

标签: r

我想使用gmailR在电子邮件正文中发送data.frame数据。我尝试了同样的htmlTable。     msg = htmlTable(data,rnames = FALSE)

html_bod <- paste0("<p> This is a test email. </p>", msg)

# sending mail
use_secret_file("/Users/abhishekgupta/Downloads/gmailR.json")



msg = htmlTable(data,rnames=FALSE)

html_bod <- paste0("<p> This is a test email. </p>", msg)

# sending mail
use_secret_file("/Users/abhishekgupta/Downloads/gmailR.json")



test_email <- mime(
  To = "1234@gmail.com",
  From = "1234@pharmeasy.in",
  Subject = "Data City Wise",
  body = html_bod,
  html =TRUE)

send_message(test_email)

1 个答案:

答案 0 :(得分:4)

您可以使用html_body()代替body参数。

加载包裹:

library(gmailr)
library(tableHTML)

使用tableHTML创建HTML表格:

msg = tableHTML(mtcars)

在表格前添加一个段落:

html_bod <- paste0("<p> This is a test email. </p>", msg)

创建MIME消息并发送:

mime() %>%
  to("1234@gmail.com") %>%
  from("1234@pharmeasy.in") %>%
  subject("Data City Wise") %>% 
  html_body(html_bod) %>% 
  send_message()

这就是gmail中电子邮件的样子:

gmail_output