Skip to contents

Add text/plain content to a message.

Usage

text(
  msg,
  content,
  disposition = "inline",
  charset = "utf-8",
  encoding = "7bit",
  language = FALSE,
  interpolate = TRUE,
  .open = "{{",
  .close = "}}",
  .envir = NULL
)

Arguments

msg

A message object.

content

A string of message content.

disposition

Should the content be displayed inline or as an attachment? Valid options are "inline" and "attachment". If set to NA then will guess appropriate value.

charset

What character set is used. Most often either "UTF-8" or "ISO-8859-1".

encoding

How content is transformed to ASCII. Options are "7bit", "quoted-printable" and "base64". Use NA or NULL for no (or "identity") encoding.

language

Language of content. If FALSE then will not include language field. If TRUE then will attempt to auto-detect language. Otherwise will use the specified language.

interpolate

Whether or not to interpolate into input using glue.

.open

The opening delimiter.

.close

The closing delimiter.

.envir

Environment used for glue interpolation. Defaults to parent.frame().

Value

A message object.

Details

The text/plain format is described in RFC 2646.

Uses glue::glue() to evaluate expressions enclosed in brackets as R code.

See also

Examples

msg <- envelope() %>% text("Hello!")

# Using {glue} interpolation.
#
name <- "Alice"
msg <- envelope() %>% text("Hello {name}.")

print(msg, details = TRUE)
#> Date:                         Thu, 11 Jul 2024 03:36:40 GMT

#> X-Mailer:                     {emayili}-0.9.1

#> MIME-Version:                 1.0

#> Content-Type:                 text/plain; 

#>                               charset=utf-8; 

#>                               format=flowed

#> Content-Transfer-Encoding:    7bit

#> Content-MD5:                  57XDXVaQowq93ca6rVsFjg==

#> 

#> Hello {name}.

# Disable {glue} interpolation.
#
msg <- envelope() %>% text("This is a set: {1, 2, 3}.", interpolate = FALSE)