17.8 Send emails based on R Markdown
With the blastula package (Iannone and Cheng 2020), you can render an Rmd document to the email body and send the email. To render an Rmd document to an email, the document needs to use the output format blastula::blastula_email
, e.g.,
---
title: Weekly Report
output: blastula::blastula_email
---
Dear Boss,
Below is an analysis of the `iris` data:
```{r}
summary(iris)
plot(iris[, -5])
```
Please let me know if it is not boring enough.
Sincerely,
John
This Rmd document should be rendered via the function blastula::render_email()
, and the output can be passed to blastula::smtp_send()
, which will send out the email. Note that smtp_send()
needs an email server as well as your credentials.
If you use RStudio Connect, you can find more examples at https://solutions.rstudio.com/examples/blastula-overview/, including automated, conditional, and parameterized emails.
References
Iannone, Richard, and Joe Cheng. 2020. Blastula: Easily Send HTML Email Messages. https://github.com/rich-iannone/blastula.