sendgrid / opensource

SendGrid Open Source Dashboard
http://github.com/sendgrid
MIT License
35 stars 13 forks source link

Send Multiple emails to the same contact in a single request #23

Open leandroPodo opened 3 years ago

leandroPodo commented 3 years ago

Hello everyone, I reach your support team and they asked me to raise an issue here.

Context: We are integrating SendGrid with our CRM and one of the main goals will be to send all the invoice emails by SendGrid. So we were running some testing with the API and one of them was sent an email to a customer that has multiple invoices. Example: One customer that has 5 or more invoices to be sent at the same time.

So we will do a single request to the API, to send multiple emails to the same contact(email addresses), the request will have the same template ID (Dynamic template), but with different "Dynamic_template_data".

In our testing, the contact is receiving only one mail, instead of five. So is that expected behavior?

Request JSON:

{
  "personalizations":[{

    "to":[{"name":"Test","email":"customer1@gmail.com"}],"subject":"Testing this","Dynamic_template_data":{"Pv2_SendGrid_Producto_luz__c":"Flexible","Pv2_SendGrid_Fecha_activacion__c":"2021-01-27 00:00:00","Pv2_SendGrid_Total_a_pagar__c":"10.00","Pv2_SendGrid_Numero_factura__c":"10000","Pv2_SendGrid_Ano_corriente__c":"2021-02-09 00:00:00","Pv2_SendGrid_Direccion__c":"Huertas 45, 28021, Madrid, Madrid","Pv2_SendGrid_Nombre__c":"Test"}},{

    "to":[{"name":"Test","email":"customer1@gmail.com"}],"subject":"Testing this","Dynamic_template_data":{"Pv2_SendGrid_Producto_luz__c":"Flexible","Pv2_SendGrid_Fecha_activacion__c":"2023-05-18 00:00:00","Pv2_SendGrid_Total_a_pagar__c":"6370.00","Pv2_SendGrid_Numero_factura__c":"62440000","Pv2_SendGrid_Ano_corriente__c":"2021-02-09 00:00:00","Pv2_SendGrid_Direccion__c":"Huertas 45, 28021, Madrid, Madrid","Pv2_SendGrid_Nombre__c":"Test"}},{

    "to":[{"name":"Test","email":"customer1@gmail.com"}],"subject":"Testing this","Dynamic_template_data":{"Pv2_SendGrid_Producto_luz__c":"Flexible","Pv2_SendGrid_Fecha_activacion__c":"2023-05-21 00:00:00","Pv2_SendGrid_Total_a_pagar__c":"6400.00","Pv2_SendGrid_Numero_factura__c":"62740000","Pv2_SendGrid_Ano_corriente__c":"2021-02-09 00:00:00","Pv2_SendGrid_Direccion__c":"Huertas 45, 28021, Madrid, Madrid","Pv2_SendGrid_Nombre__c":"Test"}},{

    "to":[{"name":"Test","email":"customer1@gmail.com"}],"subject":"Testing this","Dynamic_template_data":{"Pv2_SendGrid_Producto_luz__c":"Flexible","Pv2_SendGrid_Fecha_activacion__c":"2023-05-24 00:00:00","Pv2_SendGrid_Total_a_pagar__c":"6430.00","Pv2_SendGrid_Numero_factura__c":"63040000","Pv2_SendGrid_Ano_corriente__c":"2021-02-09 00:00:00","Pv2_SendGrid_Direccion__c":"Huertas 45, 28021, Madrid, Madrid","Pv2_SendGrid_Nombre__c":"Test"}}],

  "from": {
    "email": "from@test.com",
    "name": "Test"
  },
  "reply_to": {
    "email": "from@test.com",
    "name": "Test"
  },
  "template_id": "TEMPLATE_ID_HERE"
}
thinkingserious commented 3 years ago

Hello @leandroPodo,

Here are examples and resources that may help:

With best regards,

Elmer

leandroPodo commented 3 years ago

Hi, @thinkingserious thanks for the answer! But I already read these links, and none of them cover my case, that's why the support request me to raise an issue here. We need to send to the same contact multiple emails with the same template ID but the Dynamic_template_data will be different for each one of them.