How do I specify the template version I want to use in SendGrid?

Viewed 215

I am currently using SendGrid's Dynamic Template. I just created a new version of a template that I would like to use in development. I couldn't find any documentation on how to do that. I am using SendGrid's C# library, this is what I have so far.

var dynamicTemplateData = new Dictionary<string, string>
{
    {"name", $"{user.FirstName}"},
    { "date", appointment.AppointmentDateTime.ToLocationDateTime(location.TimeZoneInformation).ToString("f") },
    {"location", $"{location.Address} {location.Address2}. {location.City}, {location.State}"},
    {"receipt_url", $"{_appSettings.SiteUrl}appointment/{appointment.Id}"},
    {"order_id", $"{appointment.ExternalOrderId}"}
};

var msg = MailHelper.CreateSingleTemplateEmail(
    new EmailAddress("mail@xxxx.com", "xxxx"),
    new EmailAddress(user.EMail),
    "d-adwadadadadadadadadadadad",
    dynamicTemplateData);
1 Answers

I tried however, didn't find a way. So that I tried is to get a version using a template API endpoint, replace dynamic data and send an email.

You can get a template by

var response = await client.RequestAsync(method: SendGridClient.Method.GET, urlPath: "templates/" + templateId + "/versions/" + version);

Version ID will be there in the URL when you browse it,

Related