mailR: correct installation - send.mail sends string instead of .html

So, I want to send an html-file, that is created from a .Rmd file to a certain email address using the send.mail() function from the mailR package. However, instead of sending the file as a mail it only sends whatever I assign to body="example-file.html", so that the mail literally only says example-file.html.

There is an automated script running in the backend, that is identical and yields the wanted result. However, if I execute it manually, it only sends a string as email again. Hence, I assume it has something to do with my installation (in RStudio Server 3.6.3.).

Any ideas what to do or what could be the cause?

If you enclose a string in quotation marks, it is interpreted as a string. If you want to send the content of a file, you need to extract it first.

Something like that may work:

file_content <- readLines("example-file.html")

send.mail(body = file_content)

Make sure you use the html = TRUE parameter, that should take care of the headers (indicating to the email receiver that the content must be read as html and not just text). Also note that some of the more advanced features of html might not work.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.