1

ユーザーがクリックした内容に応じて、任意の形式で R マークダウン レポートを生成する R 光沢のあるアプリケーションがあります。このレポートが生成されるたびに自分自身に電子メールで送信したいのですが、オンラインではあまり見つけられないようです。誰かがこれを開始する方法を知っているかどうか疑問に思っています

4

2 に答える 2

1

Outlook を使用している場合は、RDCOMClient パッケージをお勧めします。

install.packages(RDCOMClient)
require(RDCOMClient)

OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "you@domain.com"
outMail[["subject"]] = "subject here"
outMail[["htmlbody"]] = "email text"
outMail[["Attachments"]]$Add("c:/file.blah")
outMail$Send()
于 2016-12-08T21:42:55.317 に答える
0

mailRパッケージを試すことができます。mailR github ドキュメントから、電子メールを送信し、attach.files を使用して関連レポートを添付できます。

library(mailR)
send.mail(from = "sender@gmail.com",
          to = c("recipient1@gmail.com", "recipient2@gmail.com"),
          subject = "Subject of the email",
          body = "Body of the email",
          smtp = list(host.name = "smtp.gmail.com", port = 465, ssl = TRUE,
                      user.name = "gmail_username", passwd = "password"),
          authenticate = TRUE,
          send = TRUE,
          attach.files = c("./download.log"),
          file.names = c("Download log.log"),
          file.descriptions = c("Description for download log"))

sendmailR同様の結果が得られますが、添付ファイルは を使用して電子メールの本文に追加されますmime_part()

library(sendmailR)
from <- 'you@account.com'
to   <- 'recipient@account.com'
subject <- 'Email Subject'
body <- list('Email body text.',
             mime_part(x = 'pathToAttachment', y = 'nameOfAttachment'))
sendmail(from, to, subject, msg = body,
         control = list(smtpServer='ASPMX.L.GOOGLE.COM'))
于 2016-12-08T21:29:56.230 に答える