Variable substitution in SendGrid templates with Nodejs does not work

后端 未结 1 732
慢半拍i
慢半拍i 2021-01-22 20:26

Following the USE CASE on SendGrids github does manage to send me the e-mail with the correct template, but the substitutions does apparently not work, and is left blank in the

1条回答
  •  余生分开走
    2021-01-22 20:37

    Since what I was using was dynamic templates from SendGrid, I cannot use the "substitutions" tag, but must instead use the "dynamic_template_data" tag, see this issue. When changing the msg-object to

    const msg = {
        to: '...',
        from: 'sender@example.org',
        subject: 'Hello world',
        text: 'Hello plain world!',
        html: '

    Hello HTML world!

    ', templateId: '...', dynamic_template_data: { name: 'Some One', city: 'Denver', }, };

    it works. This is not documented in the SendGrid-documentation as far as I can see.

    0 讨论(0)
提交回复
热议问题