我搜索了SO和谷歌,似乎无法找到我的问题的解决方案.我正在尝试使用sendmailR包在R中发送HTML格式的电子邮件.纯文本电子邮件工作正常,但后来无法从纯文本切换到HTML.
我的代码:
- require(sendmailR)
- from <- "alertbot@companyname.com"
- message = "<HTML><body><b>Hello</b></body></HTML>"
- to = c("me@companyname.com")
- subject = "Test Monitor Alert"
- sendmail(from,to,subject,msg = msg,control=list(smtpServer="smtp-gw1.wal-mart.com"),headers=list("Content-Type"="text/html; charset=UTF-8; format=flowed"))
解决方法
这是可能的,参见
https://stackoverflow.com/a/21930556/448145
只需添加:
只需添加:
- msg <- mime_part(message)
- msg[["headers"]][["Content-Type"]] <- "text/html"
- sendmail(from,...)