I got transaction template with following subject: Request at {{receiveDate}}. But I couldnt send substitution to it.
I am trying following code:
var msg = new SendGridMessage { };
msg.From = new EmailAddress(emailFrom.Address.ToLower(), emailFrom.DisplayName);
msg.AddTo(new EmailAddress("[email protected]"));
msg.AddSubstitution("{{receiveDate}}","date");
msg.TemplateId = ID;
var result = client.SendEmailAsync(msg).Result;
but got error: `result.StatusCode == BadRequest'. How could I fix that?
When I comment line with substitution - everything works fine.
@Seekeer look at issue #716
@Leeemons as far as I understand its about dynamic templates. But I want to use templates created on server.
Hello @Seekeer,
Please upgrade to version 9.10.0 of this SDK and see this example.
Thanks!
With Best Regards,
Elmer
None of these examples work. This library is a mess.
Hello @GiorgioG,
Do you mind sharing your code so that I may try to reproduce your issue? Thanks!
With Best Regards,
Elmer
It works for me:
msg.SetTemplateData(new { receiveDate = date });
I think it's more gracefully than method from sample.
Most helpful comment
Hello @Seekeer,
Please upgrade to version 9.10.0 of this SDK and see this example.
Thanks!
With Best Regards,
Elmer