简体   繁体   English

SendGrid 动态模板中的收件人详细信息

[英]Recipient detail in SendGrid Dynamic Template

I need to send a payload to multiple recipients in SendGrid.我需要向 SendGrid 中的多个收件人发送有效负载。 I use the Dynamic Templates to construct the email body, and all is working fine.我使用动态模板构建 email 主体,一切正常。

I would like to add a 'Hi {{recipientName}} ' line to the email but I cannot find any documentation on it, is it possible?我想在 email 中添加一行“Hi {{recipientName}} ”,但我找不到任何关于它的文档,可以吗?

I cannot include the recipient detail in the payload as a single payload goes out to many recipients我不能在有效负载中包含收件人详细信息,因为单个有效负载会发送给许多收件人

Use personalizations .使用个性化

Personalizations allow you to override these various metadata for each email in an API request.个性化允许您为 API 请求中的每个 email 覆盖这些不同的元数据。

Your request will look like this:您的请求将如下所示:

{
  "from": "gilbert@techmail.com",
  "template_id": "YOUR TEMPLATE ID",
  "personalizations": [
    {
      "to": [
        {
          "email": "john@example.com"
        }
      ],
      "substitutions": {
        "%fname%": "John",
        "%CustomerID%": "C001"
      },

    },
    {
      "to": [
        {
          "email": "peter@example.com"
        }
      ],
      "substitutions": {
        "%fname%": "Peter",
        "%CustomerID%": "C005"
      },
      "send_at": 1629723541
    }
  ]
}

and it will go as a single request.它将 go 作为一个请求。

Also look at this github comment.另请查看github 评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用动态模板将 Sendgrid 中的 email 发送给单个收件人并获取已发送的 HTML 以供保留 - How to send an email in Sendgrid to a single recipient using dynamic template and obtain the sent HTML for retention purposes SendGrid 动态模板 - 在 handlebars 中获取收件人 email - SendGrid Dynamic Templates - get recipient email in handlebars SendGrid 动态模板中的基本替换 - Basic Substitution in SendGrid Dynamic Template Sendgrid 动态数据未发送到模板 - Sendgrid dynamic data not being sent to Template Ruby on Rails 和 SendGrid; 动态模板数据未填充 - Ruby on Rails and SendGrid; dynamic template data is not populating Sendgrid - 动态模板中的车把错误消息 - Sendgrid - handlebar error msg in dynamic template SendGrid API - 无法将动态模板数据与旧模板一起使用 - SendGrid API - Cannot use dynamic template data with a legacy template 在 sendgrid 中发送多个动态模板电子邮件时出现个性化字段错误 - Personalizations field error when sending multiple dynamic template emails in sendgrid 如何在 SendGrid 代码编辑器中使用手柄在动态 email 模板中呈现所有 json 数据? - How to render all json data in dynamic email template with handlebars in SendGrid code editor? Sendgrid ~ 通过 Web Api 发送 HTML 动态模板时在哪里设置预报头? - Sendgrid ~ where to set preheader when sending HTML Dynamic Template via Web Api?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM