How to Send HTML Email Using R

How to send HTML email using R

This is possible, cf https://stackoverflow.com/a/21930556/448145
Just add:

msg <- mime_part(message)
msg[["headers"]][["Content-Type"]] <- "text/html"
sendmail(from, to, subject, msg = msg, ...)

how to send html file in the body of the mail using R?

Try the mailR package to easily send emails in HTML format as follows:

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)

Sending email without Java in R

The following works.

library(sendmailR)

msg = mime_part(bodyToSend)
msg[["headers"]][["Content-Type"]] = "text/html"

sendmail(mailFrom,mailTo,subject, msg, control=list(smtpServer= "smtpserver"))


Related Topics



Leave a reply



Submit