Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendGrid C# API template substitution issue #734

Closed
Seekeer opened this issue Sep 5, 2018 · 6 comments
Closed

SendGrid C# API template substitution issue #734

Seekeer opened this issue Sep 5, 2018 · 6 comments
Labels
difficulty: unknown or n/a fix is unknown in difficulty status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library

Comments

@Seekeer
Copy link

Seekeer commented Sep 5, 2018

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.

@Leeemons
Copy link

Leeemons commented Sep 5, 2018

@Seekeer look at issue #716

@Seekeer
Copy link
Author

Seekeer commented Sep 7, 2018

@Leeemons as far as I understand its about dynamic templates. But I want to use templates created on server.

@thinkingserious thinkingserious added type: question question directed at the library difficulty: unknown or n/a fix is unknown in difficulty status: waiting for feedback waiting for feedback from the submitter labels Sep 15, 2018
@thinkingserious
Copy link
Contributor

Hello @Seekeer,

Please upgrade to version 9.10.0 of this SDK and see this example.

Thanks!

With Best Regards,

Elmer

@GiorgioG
Copy link

None of these examples work. This library is a mess.

@thinkingserious
Copy link
Contributor

Hello @GiorgioG,

Do you mind sharing your code so that I may try to reproduce your issue? Thanks!

With Best Regards,

Elmer

@rodion-m
Copy link

It works for me:

msg.SetTemplateData(new { receiveDate = date });

I think it's more gracefully than method from sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: unknown or n/a fix is unknown in difficulty status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

6 participants