summaryrefslogtreecommitdiffstats
path: root/SendGrid/Example/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'SendGrid/Example/Program.cs')
-rw-r--r--SendGrid/Example/Program.cs31
1 files changed, 21 insertions, 10 deletions
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs
index 9da69f5..fa97707 100644
--- a/SendGrid/Example/Program.cs
+++ b/SendGrid/Example/Program.cs
@@ -17,18 +17,29 @@ namespace Example
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World!";
- // Create credentials, specifying your user name and password.
- var credentials = new NetworkCredential("username", "password");
+ SendAsync(myMessage);
- // Create a Web transport for sending email.
- var transportWeb = new Web(credentials);
-
- // Send the email.
- if (transportWeb != null)
- transportWeb.DeliverAsync(myMessage);
-
- Console.WriteLine("Done!");
Console.ReadLine();
}
+
+ private static async void SendAsync(SendGridMessage message)
+ {
+ // Create credentials, specifying your user name and password.
+ var credentials = new NetworkCredential("username", "password");
+
+ // Create a Web transport for sending email.
+ var transportWeb = new Web(credentials);
+
+ // Send the email.
+ try
+ {
+ await transportWeb.DeliverAsync(message);
+ Console.WriteLine("Sent!");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+ }
}
} \ No newline at end of file