如何在c#的SendGrid邮件中添加多个类别
本文关键字:添加 SendGrid | 更新日期: 2023-09-27 18:17:48
如何在sendgrid smtp api c#中添加多个类别?如果我使用下面的代码添加类别:
1.) var message=SendGrid.GetInstance()
2) message.Header.SetCategory("EmailName");
成功添加"EmailName"作为类别。如果我需要添加多个类别并多次编写第二步语句,那么它只创建最后一个类别并覆盖前面的类别。
谢谢
通过谷歌寻找与OP相同的东西,偶然发现了这个问题。看起来SendGrid c#库现在支持多个类别,所以我想我应该在这里添加它,以防其他人也在这里绊倒。
IEnumerable<string> categories = new string[] { "c1", "c2" };
message.Header.SetCategories(categories);
链接到github问题,这是解决:
- https://github.com/sendgrid/sendgrid-csharp/pull/31
看起来SendGrid c#库目前不支持添加多个类别。我在github上为这个问题创建了一个问题。这是一个小的修复,所以如果你想要fork这个repo,你可以很容易地自己做这个修改。