send.mail(from = "abc@gmail.com",
to = c("abc@gmail.com"),
subject = mail_subject,
body = "High_loss_gain_Imprsn_accounts.html",
html=TRUE,
attach.files = "c:/users/rkathuria/Documents/ACCOUNT_BLOCK_NO_COST_MONITOR.xlsx",
smtp = list(host.name = "aspmx.l.google.com", port = 25),
authenticate = FALSE,
send = TRUE)
在send.mail;
的正文部分,我想发送这个html表和一条"你好"消息。但是,它要么接受我的消息,要么接受 html 表。
body = "High_loss_gain_Imprsn_accounts.html"
---->此行在邮件正文中打印我的表。body = "Hello"
-->这行打印你好。
如何在邮件正文中组合在一起? <------------------------------------------------------------------------------->如果我使用 tableHTML 包并编写我的代码而不是 xtable,它将解决我在带有主题的邮件中添加 2 个表的目的吗?
mail_body1<-tableHTML(High_loss_gain_Imprsn_accounts, widths = rep(100, 11), caption="Hi, High gain loss account", collapse = 'separate')
mail_body<-paste0(mail_body1,mail_body1)
mail_subject<-paste("Account Block No Cost Monitor ", Sys.Date()-1)
send.mail(from = "abc@gmail.com",
to = c("abc@gmail.com"),
subject = mail_subject,
body = mail_body,
html=TRUE,
attach.files = "c:/users/rkathuria/Documents/ACCOUNT_BLOCK_NO_COST_MONITOR.xlsx",
smtp = list(host.name = "aspmx.l.google.com", port = 25, ssl = TRUE),
authenticate = FALSE,
send = TRUE)
我面临的新问题是通过这个smtp,邮件现在不会去。
我之前一直在努力解决这个问题,我能找到的最佳解决方案是使用xtable
生成一个带有标题的 html 表:
table <- data.frame(a = LETTERS[1:6],
b = LETTERS[7:12])
mailR::send.mail(from = "XXXXXXXX",
to = "XXXXXXXX",
subject = "Hello World",
body = xtable::print.xtable(xtable::xtable(table,
caption = "Hello World"),
type = "html",
caption.placement = "top",
include.rownames = FALSE),
html = TRUE,
smtp = list(host.name = "smtp.gmail.com",
port = 465,
user.name = "XXXXXXXX",
passwd = "XXXXXXXX",
ssl = TRUE),
authenticate = TRUE,
send = TRUE)
问题是您只能将一个对象或路径传递给body
.因此,如果您想拥有多个标题行,我认为您需要更改您的 html 对象(我还没有测试如果您在标题中放入更多文本会发生什么,所以这可能也有效(。