Skip to contents

Create dynamic templates at https://mc.sendgrid.com/dynamic-templates.

Usage

dynamic_template(sg_mail, template_id, template_data, force = FALSE)

Arguments

sg_mail

(required) mail object from package

template_id

(required) template_id start "d-" and 32-length only digit and lower case alphabet like "d-4ad23ad40a0e47d0a0232b85f24ca5c2"

template_data

A key-value list for template data. (See https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-templates)

force

pass template_id validation. default is FALSE.

Value

sg_mail class with dynamic template

Examples

mail() %>%
  dynamic_template("d-4ad23ad40a0e47d0a0232b85f24ca5c2", list(first_name = "Amanda", link = "foo"))
#> SendGrid Mail - 
#>    from   : (required)
#>    to     : (required)
#>    subject: (required)
#>    template_id: nchr[34] d-4ad23ad40a0e47d0a0232b85f24ca5c2
#>      data: json below
#> {
#>   "first_name": "Amanda",
#>   "link": "foo"
#> } 
#>    attach : (optional)

mail() %>%
  dynamic_template(template_id = "foo",
    template_data = list(first_name = "Amanda", link = "foo"),
    force = TRUE)
#> SendGrid Mail - 
#>    from   : (required)
#>    to     : (required)
#>    subject: (required)
#>    template_id: nchr[3] foo
#>      data: json below
#> {
#>   "first_name": "Amanda",
#>   "link": "foo"
#> } 
#>    attach : (optional)