1

Rmarkdown コードの結果として、html ファイルがあります。ここで、添付ファイルではなく、この html ファイルを電子メールの本文に直接含めて電子メールを送信する必要があります。私はこの投稿から解決策を試していました:「Rを使用してHTMLメールを送信する」投稿 しかし、htmlファイルではなくhtmlテキストでのみ機能するようです。ここで私がやろうとしたこと:

library(sendmailR)
from<-"<sender@enterprise.lan>"
to<-c("<reciever@enterprise.com>")
message ="./TEST.html"
subject = "Test HTML"
msg <- mime_part(message)
msg[["headers"]][["Content-Type"]] <- "file/html"
sendmail(from, to, subject, msg = msg,control=list(smtpServer="localhost"),headers=list("Content-Type"="file/html; charset=UTF-8; format=flowed"))

このトライアルは、本文ではなく「TEST.html」ファイルが添付されたメールを私に送信します。明らかに私は何か間違ったことをしています.私はこの仕事に何日も苦労しています.誰かが私を助けてくれますか?

4

1 に答える 1

1

mailR次のように、HTML 形式で簡単にメールを送信するパッケージを試してください。

send.mail(from = "sender@gmail.com",
          to = c("recipient1@gmail.com", "recipient2@gmail.com"),
          subject = "Subject of the email",
          body = "<html>The apache logo - <img src=\"http://www.apache.org/images/asf_logo_wide.gif\"></html>", # can also point to local file (see next example)
          html = TRUE,
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "gmail_username", passwd = "password", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)
于 2015-11-02T22:44:38.340 に答える