1

I am creating an html output of the dataframe so that the url in one of the column is hyperlinked. Want to embed this in email body instead of attachment, I am using RDCOMclient package.

Deb
  • 193
  • 1
  • 3
  • 20
  • Welcome to Stackoverflow. Please provide a reproducible example. Here's how: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – lukeA Jul 08 '15 at 11:01

1 Answers1

0

Forget about RDCOMclient. Try this to e.g. send the data frame df to a gmail account:

library(mailR)
library(xtable)
df <- data.frame(links = sprintf('Go <a href="%s">here</a>', c("http://stackoverflow.com/questions/31290427/how-to-embed-a-html-file-in-email-body-using-rdcomclient", "http://stackoverflow.com/")), x = 1:2)
html <- print(xtable(df), type = "html", include.rownames = FALSE, sanitize.text.function = force)
send.mail(from = "...@gmail.com",
          to = "...@gmail.com",
          subject="subject",
          body = html, html = TRUE,
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "username", passwd = "password", ssl = TRUE),
          authenticate = TRUE,
          send = TRUE)

(You may need to allow access to less secure apps.)

enter image description here

lukeA
  • 53,097
  • 5
  • 97
  • 100