This gives us a simple interface for attaching a file to the email object. When it comes time to send the email through smtp_send(), all attachments (specified by individual calls to add_attachment()) will be faithfully transmitted along with the message.

add_attachment(
  email,
  file,
  content_type = mime::guess_type(file),
  filename = basename(file)
)

Arguments

email

The email message object, as created by the compose_email() function. The object's class is email_message.

file

The filename for the file to be attached.

content_type

The MIME type for the attachment. By default, this is guessed by the mime::guess_type() function on the basis of the file's extension. The available MIME types that can be guessed are available in the mime::mimemap named character vector.

filename

the filename for the attachment. This can be different than the basename provided to file for the purpose of customization. By default, the basename of file is taken to be the attachment's filename.

Details

There are options available to specify the attachment's MIME type, its disposition, and customize the attachment's recipient-facing filename.