summaryrefslogtreecommitdiffstats
path: root/SendGrid/Example/Program.cs
diff options
context:
space:
mode:
authorbrandonmwest <brawest@gmail.com>2013-07-29 12:51:31 -0700
committerbrandonmwest <brawest@gmail.com>2013-07-29 12:51:31 -0700
commit8313c8bab44bef9fde57ac2e22f994427d8d83bd (patch)
tree1c8c5550dab4b2c6fd62ae9698c5ecaaa2d8f5a0 /SendGrid/Example/Program.cs
parent2a1b360b89ac07fab5e4a377f380bd563dfa5f7e (diff)
parent072cd3ebf52417a275b5180cd1e6841ca4aa86df (diff)
downloadsendgrid-csharp-8313c8bab44bef9fde57ac2e22f994427d8d83bd.zip
sendgrid-csharp-8313c8bab44bef9fde57ac2e22f994427d8d83bd.tar.gz
sendgrid-csharp-8313c8bab44bef9fde57ac2e22f994427d8d83bd.tar.bz2
Merge pull request #33 from sendgrid/bw-net45
Remove RestSharp, refactor to System.Net.Http.HttpClient
Diffstat (limited to 'SendGrid/Example/Program.cs')
-rwxr-xr-xSendGrid/Example/Program.cs31
1 files changed, 13 insertions, 18 deletions
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs
index 29b02e6..4c323cf 100755
--- a/SendGrid/Example/Program.cs
+++ b/SendGrid/Example/Program.cs
@@ -1,10 +1,6 @@
using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Mail;
-using System.Text;
using SendGridMail;
using SendGridMail.Transport;
@@ -15,22 +11,21 @@ namespace Example
// this code is used for the SMTPAPI examples
static void Main(string[] args)
{
- var username = "sgrid_username";
- var password = "sgrid_password";
- var from = "bar@domain.com";
- var to = new List<String>
- {
- "foo@domain.com",
- "raz@domain.com"
- };
+ // Create the email object first, then add the properties.
+ SendGrid myMessage = SendGrid.GetInstance();
+ myMessage.AddTo("anna@example.com");
+ myMessage.From = new MailAddress("john@example.com", "John Smith");
+ myMessage.Subject = "Testing the SendGrid Library";
+ myMessage.Text = "Hello World!";
- //initialize the SMTPAPI example class
- var smtpapi = new SMTPAPI(username, password, from, to);
- var restapi = new WEBAPI(username, password, from, to);
+ // Create credentials, specifying your user name and password.
+ var credentials = new NetworkCredential("username", "password");
- //use this section to test out our Web and SMTP examples!
- smtpapi.SimpleHTMLEmail();
- restapi.SimpleHTMLEmail();
+ // Create a Web transport for sending email.
+ var transportWeb = Web.GetInstance(credentials);
+
+ // Send the email.
+ transportWeb.Deliver(myMessage);
Console.WriteLine("Done!");
Console.ReadLine();