I'm trying to insert a dynamical variable into the subject line via this library.
For example: "Hello {{name}}, welcome to {{store_name}}"
My email sends off no problem, but the subject renders {{name}} and {{store_name}} as... just that. No variables are inserted.
Code example:
dynamic_template_data: {
name: "John",
store_name: "My store",
subject: "Hello {{name}}, welcome to {{store_name}}!"
}
In my template within Sendgrid UI, the subject value is: {{subject}}
I've also tried: {{{subject}}} but no go.
Email is sent and the subject line is...
Hello {{name}}, welcome to {{store_name}}
When it should be...
Hello John, welcome to My store!
You may need to generate the dynamic subject in your code. Or, try adding that dynamic subject in the html template鈥檚 subject line as opposed to in the dynamic_template_data key
Hmm.. Just found that I can't do this even within the normal email text as well.
For example, in the test data field I have:
{
"name": "john",
"text": "Hi {{name}}"
}
But {{text}} simply renders Hi {{name}}, not Hi john.
Sort of a bummer - guess I will have to do it all on my side with code. Cheers @aroach for your help anyways
Most helpful comment
Hmm.. Just found that I can't do this even within the normal email text as well.
For example, in the test data field I have:
But {{text}} simply renders Hi {{name}}, not Hi john.
Sort of a bummer - guess I will have to do it all on my side with code. Cheers @aroach for your help anyways