I've created an html file using Rmarkdown. It is stored in my home directory. I'd like to use this file to create the body of an html email which I'll send with sendmailR package (sendmail() function).
The problem is, I can't get the html to display inline; it only shows as an attachment.
Note: I'm running this from a company server which seems to not work with other email packages in R. I'm open to alternatives using other packages, but I can't seem to get it to play nice with smtp authentication.
Here's the code that's generating an attachment:
msg2 = list(mime_part(x =
"/home/markdown_test/markdown_test.html",
name = "markdown_test.html"))
## Override content type.
#msg2[["headers"]][["Content-Type"]] = "text/html"
msg2[['headers']]$`Content-Disposition`= "inline"
sendmail(from = "test@gmail.com",
to = c("test@gmail.com"),
subject = "TEst Subject",
msg = msg2,
html = TRUE,
smtp = list(
host.name = "aspmx.l.google.com",
port = 25,
user.name = "abc@gmail.com",
passwd = "pwd",
ssl = TRUE
),
authenticate = TRUE,
send = TRUE)
I've tried various combinations of updating the headers line; in some cases no email hits the inbox at all. in other cases an email comes through, but with an empty body an an attachment titled "markdown_test.html." Note that this attachment can be opened and does have the content I'd like in the body of the email.