The compose_email() function allows us to easily create an email message. We can incorporate character vectors into the message body, the header, or the footer.

compose_email(
  body = NULL,
  header = NULL,
  footer = NULL,
  title = NULL,
  ...,
  template = blastula_template
)

Arguments

The three layout sections for an email message (ordered from top to bottom). Markdown text can be supplied to each of these by using the md() text helper function. Alternatively, we can supply a set of block_*() calls enclosed within the blocks() function to take advantage of precomposed HTML blocks.

title

The title of the email message. This is not the subject but the HTML title text which may appear in limited circumstances.

...

Additional arguments to pass to the template function. If you're using the default template, you can use font_family to control the base font, and content_width to control the width of the main content; see blastula_template(). By default, the content_width is set to 1000px. Using widths less than 600px is generally not advised but, if necessary, be sure to test such HTML emails with a wide range of email clients before sending to the intended recipients. The Outlook mail client (Windows, Desktop) does not respect content_width.

template

An email template function to use. The default is blastula_template().

Value

An email_message object.

Examples

# Create a simple email message using
# Markdown-formatted text in the `body`
# and `footer` sections with the `md()`
# text helper function
email <-
  compose_email(
    body = md(
"
## Hello!

This is an email message that was generated by the blastula package.

We can use **Markdown** formatting with the `md()` function.

Cheers,

The blastula team
"),
  footer = md(
"
sent via the [blastula](https://rstudio.github.io/blastula) R package
")
)

# The email message can always be
# previewed by calling the object
if (interactive()) email