Skip to content

Commit 9dd9ebb

Browse files
authored
Added template example for sending mail with Mail Helper
1 parent 4c8297a commit 9dd9ebb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

SendGrid/Example/Example.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ private static void HelloEmail()
3131
Mail mail = new Mail(from, subject, to, content);
3232
Email email = new Email("[email protected]");
3333
mail.Personalization[0].AddTo(email);
34-
34+
35+
//If you want to use a tempalte
36+
//Adding this will replace the above added subject and content
37+
mail.TemplateId = "TEMPLATE_ID";
38+
mail.Personalization[0].AddSubstitution("[KEY_1]", "VALUE_1");
39+
mail.Personalization[0].AddSubstitution("[KEY_2]", "VALUE_1");
40+
41+
42+
43+
3544
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
3645
Console.WriteLine(response.StatusCode);
3746
Console.WriteLine(response.Body.ReadAsStringAsync().Result);

0 commit comments

Comments
 (0)