RStudio Connect allows you to schedule emails to send using R Markdown. It uses a special type of YAML using the top-level field rmd_output_metadata that tells RStudio Connect about the email output. Several rsc_* fields exist to specify different components of the email, which can be set in the YAML header or programmatically using rmarkdown::output_metadata(). See the RStudio Connect documentation for more. yml_output_metadata() allows you to add any type of content to the rmd_output_metadata field.

  rsc_email_subject = yml_blank(),
  rsc_email_body_html = yml_blank(),
  rsc_email_body_text = yml_blank(),
  rsc_email_images = yml_blank(),
  rsc_output_files = yml_blank(),
  rsc_email_attachments = yml_blank(),
  rsc_email_suppress_scheduled = yml_blank(),
  rsc_email_suppress_report_attachment = yml_blank(),
  resource_files = yml_blank(),

yml_output_metadata(.yml, ...)



a yml object created by yml(), as_yml(), or returned by a yml_*() function


The subject of the email. A report without an rsc_email_subject entry uses its published document name.

rsc_email_body_html, rsc_email_body_text

The body of the email, either in plain text or HTML. A report with neither entry uses an automatically generated, plain-text body with a link to the report’s URL.


Images to embed in the email. The embedded image must have a Content ID that is used in the body of the HTML and when providing the image to rsc_email_images, and the image itself must be base64-encoded, e.g. with the base64enc package.


A vector of file names that should be available after the report has rendered. If you list a file that does not exist after rendering your report, Connect will log a message but continue trying to processing the other files listed. If the output files are not generated during the rendering of your report, then you will also need to list them in resource_files when you upload your report to Connect.


A vector of file names that should be attached to the email.


Logical. Should the email schedule be suppressed? Default is FALSE.


Logical. Should the rendered document be included as an attachment? Default is TRUE.


A file or files to host on RStudio Connect that is not generated by your report, e.g. an existing file.


additional named R objects, such as characters or lists, to transform into YAML


a yml object

See also


yml() %>% yml_rsconnect_email( rsc_email_subject = "Quarterly report", rsc_output_files = "data.csv", rsc_email_attachments = c("attachment_1.csv", "attachment_2.csv") )
#> --- #> author: Malcolm Barrett #> date: '`r format(Sys.Date())`' #> rmd_output_metadata: #> rsc_email_subject: Quarterly report #> rsc_output_files: data.csv #> rsc_email_attachments: #> - attachment_1.csv #> - attachment_2.csv #> --- #>