Learn R Programming

emayili (version 0.4.4)

attachment: Add attachments to a message object

Description

Add attachments to a message object

Usage

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

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

Should the content be displayed inline or as an attachment?

Value

A message object.

Examples

Run this code
# NOT RUN {
library(magrittr)

path_mtcars  <- tempfile(fileext = ".csv")
path_cats    <- tempfile(fileext = ".jpg")
path_scatter <- tempfile(fileext = ".png")

write.csv(mtcars, path_mtcars)

download.file("https://bit.ly/2P4LUO8", path_cats, quiet = TRUE)

png(path_scatter)
plot(1:10)
dev.off()

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

file.remove(path_cats, path_scatter, path_mtcars)
# }

Run the code above in your browser using DataLab