【问题标题】:Recipient detail in SendGrid Dynamic TemplateSendGrid 动态模板中的收件人详细信息
【发布时间】:2021-08-16 12:30:32
【问题描述】:

我需要向 SendGrid 中的多个收件人发送有效负载。我使用动态模板来构建电子邮件正文,一切正常。

我想在电子邮件中添加“Hi {{recipientName}}”行,但我找不到任何文档,可以吗?

我无法在有效负载中包含收件人详细信息,因为单个有效负载会发送给许多收件人

【问题讨论】:

  • 什么编程语言
  • 另外,为什么不使用 for 循环

标签: sendgrid


【解决方案1】:

使用personalizations

个性化允许您为 API 请求中的每封电子邮件覆盖这些不同的元数据。

您的请求将如下所示:

{
  "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
    }
  ]
}

它将作为单个请求进行。

另请看thisgithub 评论。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-12
    • 2016-12-19
    • 1970-01-01
    • 2016-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多