我希望能够使用gmailR包通过电子邮件内联(而不是附件)发送R生成的HTML报告.我无法使用gmailr发送基本的HTML电子邮件.我尝试了以下失败,需要一些帮助:
@H_301_25@解决方法
library(gmailr) gmail_auth("oauth.token.json",scope = "compose") test_email <- mime() %>% to("you@gmail.com") %>% from("me@gmail.com") %>% subject("This is a subject") test_email$body <- "I wish <b>this</b> was bold" send_message(test_email)
结果:消息成功发送,但正文是纯文本 – 不是HTML
尝试2
test_email <- mime() %>% to("you@gmail.com") %>% from("me@gmail.com") %>% subject("This is a subject") %>% html_body("I wish <b>this</b> was bold") test_email$body
结果:test_email $body为NULL
尝试3
test_email <- mime() %>% to("you@gmail.com") %>% from("me@gmail.com") %>% subject("This is a subject") test_email$body <- html_body("I wish <b>this</b> was bold")
结果:mime $parts中的错误:$operator对原子向量无效
尝试4
test_email <- mime() %>% to("you@gmail.com") %>% from("me@gmail.com") %>% subject("This is a subject") test_email$parts <- c(html_body("I wish <b>this</b> was bold"),text_body("plain"))
结果:mime $parts中的错误:$operator对原子向量无效
嗯 – 这是我试过的:
library(gmailr) gmail_auth('mysecret.json',scope = 'compose') test_email <- mime() %>% to("to@gmail.com") %>% from("from@gmail.com") %>% subject("This is a subject") %>% html_body("<html><body>I wish <b>this</b> was bold</body></html>") send_message(test_email)
似乎这个伎俩就是简单地放入真正的HTML – 包括< html>和< body> – 让gmail了解.