Bulk email with to {{name}} in body with substituions not working
Issue Summary
Hi, i need to send bulk email with a static HTML template and dynamic name in each mail
Steps to Reproduce
{
"personalizations": [
{
"to": [
{
"email": "[email protected]"
},
{
"email": "[email protected]"
},
{
"email": "[email protected]"
}
],
"substitutions":{
"{{name}}":["dfsda","sdfb","cfsd"]
},
"subject": "Hello, World!"
}
],
"from": {
"email": "[email protected]",
"name": "test"
},
"subject": "Hello, World!",
"content": [
{
"type": "text/html",
"value": "<html><p>Hello {{name}}, world!</p></html>"
}
]
}
here , each maiil should have first_name individually in each mail, but instead it is giving me errror
{
"errors": [
{
"message": "Bad Request",
"field": null,
"help": null
}
]
}
neither %name%,-name- and nor -name- is working
Technical details:
- sendgrid-nodejs Version: master (latest commit: [commit number])
- Node.js Version: 4.1.2
Hi @apoorv-1310,
Could you please extract the error message, like so? Thanks!
Also, would you mind providing the full source code that was used to generate that payload? I believe "{{name}}":["dfsda","sdfb","cfsd"] should probably be "name":["dfsda","sdfb","cfsd"].
Thanks!
With Best Regards,
Elmer
i'm facing kind of same issue ..
sending from node js
this is my msg payload
msg = { "from": { "email": "[email protected]" }, "personalizations": [{ "to": [{ "email": "[email protected]" }], "dynamic_template_data": { "name": "jhon", "plan": "xyz", "amount": "80000", }, }], "subject": "Notification", "template_id": "<my-template-id>", };
SGMail.send(msg);
this is my template
Hello {{name}}, some random text plan: {{plan}} amount you paid: {{amount}}
substitution data is missing in mail .. any idea?
Hi @satishsathya11,
Please move the dynamic_template_data inside of the personalizations object like so.
Thanks!
@apoorv-1310
I think what you are looking for is below. Since you are using a substitution per email you need to break each to into its own container. Hopefully, the below example will help.
{
"personalizations": [
{
"to": [
{
"email": "[email protected]"
}
],
"substitutions":{
"{{name}}":{"dfsda"}
},
"subject": "Hello, World!"
},
{
"to": [
{
"email": "[email protected]"
}
],
"substitutions":{
"{{name}}":{"sdfb"}
},
"subject": "Hello, World!"
},
{
"to": [
{
"email": "[email protected]"
}
],
"substitutions":{
"{{name}}":{"cfsd"}
},
"subject": "Hello, World!"
}
],
"from": {
"email": "[email protected]",
"name": "test"
},
"subject": "Hello, World!",
"content": [
{
"type": "text/html",
"value": "<html><p>Hello {{name}}, world!</p></html>"
}
]
}