This sends the email. But none of the substitutions replace the template. I just followed the both the examples mentioned in Transactional Templates section and tried out this as well. But nothing replaces the variables in HTML template by the defined substitutions.
This is my template
<html>
<head>
<title></title>
</head>
<body>
Hello {{name}},
<br /><br/>
I'm glad you are trying out the template feature!
<br /><br/>
<%body%>
<br /><br/>
I hope you are having a great day in {{city}} :)
<br /><br/>
</body>
</html>
with the header as <%subject%>
And this is my code .
sgMail.setSubstitutionWrappers('{{', '}}'); // Configure the substitution tag wrappers globally
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello world',
text: 'Hello plain world!',
html: '<p>Hello HTML world!</p>',
templateId: 'd-5d04c39e40054d118b4de3fba82a09ac',
substitutions: {
name: "Some One",
city: "Denver"
},
};
sgMail.send(msg);
This sends the email, however it receives like this
Hello ,
I'm glad you are trying out the template feature!
<%body%>
I hope you are having a great day in :)
with the subject of <%subject%>
.
Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?
I was expecting an email like this (with subject as Hello world
)
Hello Some One,
I'm glad you are trying out the template feature!
I hope you are having a great day in Denver :)
Tested in Template Engine with test data as
{
"name": "Some One",
"city": "Denver"
}
This shows correctly in the template engine.
I'm having the same issue. When building mail via Mail.create
from @sendmail/helpers
, I'm getting mail.substitutions
= null
@bbbneo333 check the last solutions given in this issue. It worked for me
Yes. Substituting substitutions
with personalizations.0.dynamic_template_data
worked for me. Thanks.
Thanks for helping out @pankaja92 and thanks to @bbbneo333 for following up!
The issue is that if you are using the new dynamic templates, the API call is a bit different. I'll be updating this SDK's documentation shortly to reflect those changes.
Most helpful comment
Thanks for helping out @pankaja92 and thanks to @bbbneo333 for following up!
The issue is that if you are using the new dynamic templates, the API call is a bit different. I'll be updating this SDK's documentation shortly to reflect those changes.