我正在创建数据框的html输出,以便其中一列中的url是超链接的。想要将其嵌入电子邮件正文而不是附件中,我使用的是RDCOMclient包。
答案 0 :(得分:0)
忘记RDCOMclient。试试这个,例如将数据框df
发送到Gmail帐户:
library(mailR)
library(xtable)
df <- data.frame(links = sprintf('Go <a href="%s">here</a>', c("http://stackoverflow.com/questions/31290427/how-to-embed-a-html-file-in-email-body-using-rdcomclient", "http://stackoverflow.com/")), x = 1:2)
html <- print(xtable(df), type = "html", include.rownames = FALSE, sanitize.text.function = force)
send.mail(from = "...@gmail.com",
to = "...@gmail.com",
subject="subject",
body = html, html = TRUE,
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "username", passwd = "password", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
(您可能需要允许access to less secure apps。)