【问题标题】:How do I specify the template version I want to use in SendGrid?如何指定要在 SendGrid 中使用的模板版本?
【发布时间】:2020-12-15 15:41:27
【问题描述】:

我目前正在使用 SendGrid 的动态模板。我刚刚创建了一个新版本的模板,我想在开发中使用它。我找不到任何关于如何做到这一点的文档。 我正在使用 SendGrid 的 C# 库,这是我目前所拥有的。

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);

【问题讨论】:

    标签: c# sendgrid


    【解决方案1】:

    我试过了,没有找到方法。所以我尝试的是使用模板 API 端点获取版本,替换动态数据并发送电子邮件。

    您可以通过

    获取模板

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

    当您浏览它时,版本 ID 会出现在 URL 中,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-25
      • 2016-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多