gpt4 book ai didi

c# - SendGrid 给邮件添加类别

转载 作者:行者123 更新时间:2023-12-04 02:51:55 24 4
gpt4 key购买 nike

我正在使用 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);
}
}

最佳答案

谢谢 Kami ,我试过你的答案,它工作正常。

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

关于c# - SendGrid 给邮件添加类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54690326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com