Sendgrid and template id

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

Hi! I’m trying to use the Dynamic Template option from Sendgrid, but I don’t know how can I send the template id and the dynamic_template_data.

        await strapi.plugins['email'].services.email.sendTemplatedEmail({
        to: "drolegc@gmail.com"
    }, {
        subject: 'Nueva orden',
        text: 'Nueva orden - text',
        html: '',
    }, {
        temaplteId: "d-d87cb96227e641e9a8fcda2c0b11edc7",
        dynamic_template_data: {
            user: order.user,
            order: order
        }
    })

That’s the way I’m currently implementing, but it does not show the template.

For this, we don’t have to use sendTemplatedEmail. Just the function send with

    template_id: "d-d87cb96227e641e9a8fcda2c0b11edc7",
    dynamic_template_data: {
        user: order.user,
        order: order
    }

(in my case)

PD: We can use the attachment camp to send files ( Sending Email with Attachments using SendGrid and Node.js - Twilio)

Hello @drolegc,

I have similar issue:

await strapi.plugins[‘email’].services.email.send({
subject: ‘Test Sample Here’,
templateId: “…”,
dynamicTemplateData: {
generatedCustomCode: ‘test50’,
},
});

but I don’t get the Dynamic Template in the email - just the empty content. I also tried template_id and dynamic_template_data with underscores.

await strapi.plugins[‘email’].services.email.send({
to: ‘nin.tran52@gmail.com’,
from: ‘nin.tran52@gmail.com’’,
template_id: “d-a2e76f714d1b4a2436b493e831cab443”,
});
It works well

I cannot get it to work either, the mail is sent but the dynamica data is missing in the email itself. I have this code:

            await strapi.plugins['email'].services.email.send({
              to: user.parent_email,
              from: 'hidden',
              template_id: 'd-e0a5b89b0c594f40ad6f1bd98fd58f44',
              dynamic_template_data: {
                firstName: user.first_name,
                password,
              },
            })

Who know how to solve this!?