Composing an Email Message

An email message can be easily created with the compose_email() function. Want to attach files to the message? That’s a cinch with add_attachment(). We can experiment with a example email message using prepare_test_message().

compose_email()

Create the email message body

add_attachment()

Add a file attachment to an email message

prepare_test_message()

Prepare a email test message object

blastula_template()

Default template for compose_email()

Add Inline Components

Several types of useful HTML fragments generated and incorporated into the email message content. We can create and use CTA buttons, links to images, and more!

add_image()

Create an HTML fragment for an embedded image

add_imgur_image()

Deploy a local image to Imgur and create an image tag

add_cta_button()

Create an HTML fragment for a CTA button

add_ggplot()

Create an HTML fragment for an embedded ggplot image

add_readable_time()

Create a string with a more readable date/time

md()

Interpret input text as Markdown-formatted text

%>%

The magrittr pipe

HTML Blocks

We can use HTML blocks to compose our email message. These functions are placed inside of an unnamed list and the order determines the ordering of the blocks. With these responsive, higher-level components, we can create sophisticated email messages with minimal effort.

blocks()

An enclosure for all HTML block functions

block_title()

A block with large title text

block_text()

A block of text

block_spacer()

A spacer block

block_articles()

A block of one, two, or three articles with a multicolumn layout

block_social_links()

A block of social sharing icons with links

article()

Specify the components of an article

social_link()

Specify the components of a social link

Email Sending through SMTP

Once the email looks good enough to send, we can send it through an SMTP server, with the MailGun service, or simply extract the HTML message body and go elsewhere. There is also the convenient option to create and store SMTP credentials with either the create_smtp_creds_file() or the create_smtp_creds_key() function.

smtp_send()

Send an email message through SMTP

send_by_mailgun()

Send an email message through the Mailgun API

get_html_str()

Get the HTML content of an email message

create_smtp_creds_file()

Store SMTP credentials in a file

create_smtp_creds_key()

Store SMTP credentials in the system's key-value store

creds() creds_anonymous() creds_envvar() creds_key() creds_file()

Helpers for supplying SMTP credentials

view_credential_keys()

View all available blastula credential keys

delete_credential_key()

Delete a single blastula credential key

delete_all_credential_keys()

Delete all blastula credential keys

Email Sending through RStudio Connect

Using the RStudio Connect service, it’s possible to publish R Markdown documents and provide a scheduled email based on the report. Example .Rmd documents can be generated by using the prepare_rsc_example_files() function. These files constitute a working example for a publishing workflow that uses the render_connect_email() and attach_connect_email() functions.

render_email() render_connect_email()

R Markdown render functions for the blastula_email output format

attach_connect_email()

Associate an email when publishing an R Markdown document to RStudio Connect

blastula_email()

The R Markdown blastula_email output format

suppress_scheduled_email()

Suppress any scheduled emailing in RStudio Connect

prepare_rsc_example_files()

Prepare example files for RStudio Connect emailing with R Markdown