@@ -3,6 +3,8 @@ This documentation provides examples for specific use cases. Please [open an iss
33# Table of Contents
44
55* [ Attachments] ( #attachments )
6+ * [ Custom Personalization Usage]
7+ * [ Multiple tos, ccs and bccs] ( #multiple_tos_ccs_bccs )
68* [ Transactional Templates] ( #transactional_templates )
79
810<a name =" attachments " ></a >
@@ -178,7 +180,13 @@ namespace Example
178180 }
179181}
180182```
181- ## Use Personalization to manipulate email according to recipient
183+
184+ <a name =" multiple_tos_ccs_bccs " ></a >
185+ # Custom Personalization Usage - Multiple tos, ccs and bccs
186+
187+ In this example, each email recipient receives the same email and they can see each others email address, except for the bccs.
188+
189+ For more on [ Personalizations] ( https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html ) , please see the documentation.
182190
183191``` csharp
184192using System ;
@@ -201,33 +209,31 @@ namespace Example
201209 var apiKey = Environment .GetEnvironmentVariable (" NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY" );
202210 var client = new SendGridClient (apiKey );
203211 var msg = new SendGridMessage ();
204- msg .
SetFrom (
new EmailAddress (
" [email protected] " ,
" Example User" ));
205- msg .SetSubject (" Global Subject" );
206- msg .
AddTo (
new EmailAddress (
" [email protected] " ));
207- msg .
AddTo (
new EmailAddress (
" [email protected] " ),
0 ,
new Personalization ()
212+ msg .
SetFrom (
new EmailAddress (
" [email protected] " ,
" Test1" ));
213+ var personalization = new Personalization ()
208214 {
209- Subject = " Personalization Subject " ,
215+ Subject = " Best Subject Line Ever " ,
210216 Tos = new List <EmailAddress >()
211217 {
212- new EmailAddress () { Email = " Test12 @example.com" , Name = " test12 " },
213- new EmailAddress () { Email = " Test13 @example.com" , Name = " Test13 " },
214- new EmailAddress () { Email = " Test14 @example.com" , Name = " Test14 " },
218+ new EmailAddress () { Email = " test2 @example.com" , Name = " Test2 " },
219+ new EmailAddress () { Email = " test3 @example.com" , Name = " Test3 " },
220+ new EmailAddress () { Email = " test4 @example.com" , Name = " Test4 " },
215221 },
216222 Bccs = new List <EmailAddress >()
217223 {
218- new EmailAddress () { Email = " Test15 @example.com" , Name = " Test15 " },
219- new EmailAddress () { Email = " Test16 @example.com" , Name = " Test16 " },
220- new EmailAddress () { Email = " Test17 @example.com" , Name = " Test17 " },
224+ new EmailAddress () { Email = " test5 @example.com" , Name = " Test5 " },
225+ new EmailAddress () { Email = " test6 @example.com" , Name = " Test6 " },
226+ new EmailAddress () { Email = " test7 @example.com" , Name = " Test7 " },
221227 },
222228 Ccs = new List <EmailAddress >()
223229 {
224- new EmailAddress () { Email = " Test25 @example.com" , Name = " Test25 " },
225- new EmailAddress () { Email = " Test26 @example.com" , Name = " Test26 " },
226- new EmailAddress () { Email = " Test27 @example.com" , Name = " Test27 " },
230+ new EmailAddress () { Email = " test8 @example.com" , Name = " Test8 " },
231+ new EmailAddress () { Email = " test9 @example.com" , Name = " Test9 " },
232+ new EmailAddress () { Email = " test10 @example.com" , Name = " Test10 " },
227233 }
228- });
229- var mesage = msg .Serialize ( );
230- msg .AddContent (MimeType .Text , " I'm replacing the <strong>body tag</strong> " );
234+ }
235+ msg .
AddTo ( new EmailAddress ( " [email protected] " ), 0 , personalization );
236+ msg .AddContent (MimeType .Text , " Hello Email from the SendGrid C# Library " );
231237 var response = await client .SendEmailAsync (msg );
232238 Console .WriteLine (response .StatusCode );
233239 Console .WriteLine (response .Headers .ToString ());
0 commit comments