summaryrefslogtreecommitdiffstats
path: root/src/Example/Program.cs
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-12-12 23:58:19 -0800
committerElmer Thomas <elmer@thinkingserious.com>2016-12-12 23:58:19 -0800
commit83a0891c8917d06031571015e24c1acf88ac4ae2 (patch)
tree7b7f015a1c4f8a587624ada56a0af7746ef0a882 /src/Example/Program.cs
parentff603f56e723d3e49c453cfdfe8dcf05617b6b50 (diff)
downloadsendgrid-csharp-origin/single-email.zip
sendgrid-csharp-origin/single-email.tar.gz
sendgrid-csharp-origin/single-email.tar.bz2
Properties FTW, Cancellation Tokens, Reorganizeorigin/single-email
Based on feedback from @darrelmiller and @jkewley on issue #331 and @taspeotis on issue 317. See ExampleCore for working example.
Diffstat (limited to 'src/Example/Program.cs')
-rw-r--r--src/Example/Program.cs32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/Example/Program.cs b/src/Example/Program.cs
index ab7b4ec..08c3b54 100644
--- a/src/Example/Program.cs
+++ b/src/Example/Program.cs
@@ -19,14 +19,38 @@ namespace Example
string apiKey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
Client client = new Client(apiKey);
+ // Generic Hello World Send using the Mail Helper
+ var msg = new SendGridMessage()
+ {
+ From = new EmailAddress("dx@sendgrid.com", "DX Team"),
+ Personalization = new List<Personalization>() {
+ new Personalization() {
+ Tos = new List<EmailAddress>() {
+ new EmailAddress("elmer.thomas@sendgrid.com", "Elmer Thomas")
+ }
+ }
+ },
+ Subject = "Hello World from the SendGrid CSharp Library Helper!",
+ Contents = new List<Content>() {
+ new PlainTextContent("Hello, Email from the helper [SendEmailAsync]!"),
+ new HtmlContent("<strong>Hello, Email from the helper! [SendEmailAsync]</strong>")
+ }
+ };
+
+ var response = await client.SendEmailAsync(msg);
+ Console.WriteLine(response.StatusCode);
+ Console.WriteLine(response.Headers);
+ Console.ReadLine();
+
// Send a Single Email using the Mail Helper
- var from = new MailAddress("dx@sendgrid", "DX Team");
+ var from = new EmailAddress("dx@sendgrid", "DX Team");
var subject = "Hello World from the SendGrid CSharp Library Helper!";
- var to = new MailAddress("elmer@sendgrid.com", "Elmer Thomas");
+ var to = new EmailAddress("elmer@sendgrid.com", "Elmer Thomas");
var contentText = "Hello, Email from the helper [SendSingleEmailAsync]!";
- var contentHTML = "<strong>Hello, Email from the helper! [SendSingleEmailAsync]</strong>";
+ var contentHtml = "<strong>Hello, Email from the helper! [SendSingleEmailAsync]</strong>";
+ msg = MailHelper.CreateSingleEmail(from, to, subject , contentText, contentHtml);
- Response response = await client.Mail.SendSingleEmailAsync(from, to, subject , contentText, contentHTML);
+ response = await client.SendEmailAsync(msg);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Headers);
Console.ReadLine();