Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Multiple Categories in the SendGrid Email in C#

Tags:

c#

sendgrid

How to add multiple categories in the sendgrid smtp api in c#? If I use the below code to add the category :

1.) var message=SendGrid.GetInstance();

2.) message.Header.SetCategory(“EmailName”);

It adds the "EmailName" as category successfully. If I need to add multiple categories and write the second step statement multiple times then it creates only the last category and overrides the previous categories.

Thanks

like image 980
Web Development Hurricane Avatar asked Nov 15 '25 12:11

Web Development Hurricane


1 Answers

Looking for same thing as OP via google and stumbled on this question. It looks like SendGrid C# library now supports multiple categories, so thought I'd add it here in case others stumble here too.

IEnumerable<string> categories = new string[] { "c1", "c2" };
message.Header.SetCategories(categories);

Link to github issue where this was resolved:

  • https://github.com/sendgrid/sendgrid-csharp/pull/31
like image 104
Jason W Avatar answered Nov 17 '25 08:11

Jason W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!