Add attachments to a message object

attachment(
  msg,
  path,
  name = NA,
  type = NA,
  cid = NA,
  disposition = "attachment"
)

Arguments

msg

A message object.

path

Path to file.

name

Name to be used for attachment (defaults to base name of path).

type

MIME type or NA, which will result in a guess based on file extension.

cid

Content-ID or NA.

disposition

How is attachment to be presented ("inline" or "attachment")?

Value

A message object.

Examples

path_mtcars <- tempfile(fileext = ".csv")
path_scatter <- tempfile(fileext = ".png")
path_cats <- system.file("cats.jpg", package = "emayili")

write.csv(mtcars, path_mtcars)

png(path_scatter)
plot(1:10)
dev.off()
#> agg_png 
#>       2 

msg <- envelope() %>%
  attachment(path_mtcars) %>%
  # This attachment will have file name "cats.jpg".
  attachment(path_cats, name = "cats.jpg", type = "image/jpeg") %>%
  attachment(path_scatter, cid = "scatter")

file.remove(path_scatter, path_mtcars)
#> [1] TRUE TRUE