【问题标题】:SendGrid Add Category to mailSendGrid 将类别添加到邮件
【发布时间】:2019-02-14 12:23:18
【问题描述】:

我正在使用 SendGrid,我想在电子邮件中添加一个或多个类别,但添加的类别尚未发送!

这是代码:

internal class Example
{
    private static void Main()
    {
        Execute().Wait();
    }

    static async Task Execute()
    {
        //FYI, the following three variables are not real
        var apiKey = "SG.XXX";
        var fromEmail = "";
        var toEmail = "";

        var client = new SendGridClient(apiKey);
        var from = new EmailAddress(fromEmail);
        var subject = "Sending with SendGrid is Fun";
        var to = new EmailAddress(toEmail);
        var plainTextContent = "and easy to do anywhere, even with C#";
        var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
        var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
        msg.AddHeader("category", "cat1"); //This line does nothing!
        var response = await client.SendEmailAsync(msg);
    }
}

【问题讨论】:

标签: c# asp.net sendgrid


【解决方案1】:

谢谢Kami,我试过你的回答,效果很好。

我将这一行 msg.AddHeader("category", "cat1"); 替换为 msg.AddCategory("cat1");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多