summaryrefslogtreecommitdiffstats
path: root/SendGrid/Example
diff options
context:
space:
mode:
authorCJ Buchmann <cj.buchmann@sendgrid.com>2012-01-13 16:20:58 -0800
committerCJ Buchmann <cj.buchmann@sendgrid.com>2012-01-13 16:20:58 -0800
commit0bb4eb03b1f478df60c1f14da63d42aba8281efe (patch)
tree187261ef4aed777a08be8388685d9cd5214c92dd /SendGrid/Example
parent39d5fb81bec319810565a8b7cf0cbd2e9e985c66 (diff)
downloadsendgrid-csharp-0bb4eb03b1f478df60c1f14da63d42aba8281efe.zip
sendgrid-csharp-0bb4eb03b1f478df60c1f14da63d42aba8281efe.tar.gz
sendgrid-csharp-0bb4eb03b1f478df60c1f14da63d42aba8281efe.tar.bz2
committing before tyler breaks my stuff, with his not good enough stuff
Diffstat (limited to 'SendGrid/Example')
-rwxr-xr-xSendGrid/Example/Program.cs18
-rwxr-xr-xSendGrid/Example/SMTPAPI.cs70
2 files changed, 72 insertions, 16 deletions
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs
index 0bdaacd..4709470 100755
--- a/SendGrid/Example/Program.cs
+++ b/SendGrid/Example/Program.cs
@@ -11,7 +11,7 @@ namespace Example
{
class Program
{
- static void Main(String[] args)
+ /*static void Main(String[] args)
{
var restInstance = REST.GetInstance(new NetworkCredential("cjbuchmann", "Gadget_15"));
@@ -29,13 +29,13 @@ namespace Example
Console.WriteLine("Message Sent");
Console.WriteLine("DONE!");
- }
+ }*/
// this code is used for the SMTPAPI examples
- /*static void Main(string[] args)
+ static void Main(string[] args)
{
- var username = "sgrid_username";
- var password = "sgrid_email";
+ var username = "cjbuchmann";
+ var password = "gadget15";
var from = "cj.buchmann@sendgrid.com";
var to = new List<String>
{
@@ -54,7 +54,6 @@ namespace Example
//initialize the SMTPAPI example class
var smtpapi = new SMTPAPI(username, password, from, to);
- var restpapi = new RESTAPI(username, password, from, to, null, null);
//send a simple HTML encoded email.
//smtpapi.SimpleHTMLEmail();
@@ -68,7 +67,10 @@ namespace Example
//send an open tracking enabled email.
//smtpapi.EnableOpenTrackingEmail();
- restpapi.SimpleHTMLEmail();
- }*/
+ //send an open tracking enabled email.
+ smtpapi.EnableClickTrackingEmail();
+
+ Console.ReadLine();
+ }
}
}
diff --git a/SendGrid/Example/SMTPAPI.cs b/SendGrid/Example/SMTPAPI.cs
index 2ee8927..b46520b 100755
--- a/SendGrid/Example/SMTPAPI.cs
+++ b/SendGrid/Example/SMTPAPI.cs
@@ -22,6 +22,9 @@ namespace Example
_to = recipients;
}
+ /// <summary>
+ /// Send a simple HTML based email
+ /// </summary>
public void SimpleHTMLEmail()
{
//create a new message object
@@ -49,6 +52,9 @@ namespace Example
smtpInstance.Deliver(message);
}
+ /// <summary>
+ /// Send a simple Plain Text email
+ /// </summary>
public void SimplePlaintextEmail()
{
//create a new message object
@@ -76,9 +82,13 @@ namespace Example
smtpInstance.Deliver(message);
}
+ /// <summary>
+ /// Enable The Gravatar Filter.
+ /// Currently the filter a 1x1 pixel gravatar image.
+ /// Find more info at http://docs.sendgrid.com/documentation/apps/gravatar/
+ /// </summary>
public void EnableGravatarEmail()
{
- var header = new Header();
//create a new message object
var message = SendGrid.GenerateInstance();
@@ -95,7 +105,7 @@ namespace Example
message.Html = "<p style='color:red';>Hello World Gravatar Email</p>";
//set the message subject
- message.Subject = "Hello World Simple Test";
+ message.Subject = "Hello World Gravatar Test";
//create an instance of the SMTP transport mechanism
var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
@@ -103,13 +113,14 @@ namespace Example
//enable gravatar
message.EnableGravatar();
- Console.WriteLine(header.AsJson());
-
- Console.WriteLine("done");
//send the mail
smtpInstance.Deliver(message);
}
+ /// <summary>
+ /// Enable the Open Tracking to track when emails are opened.
+ /// http://docs.sendgrid.com/documentation/apps/open-tracking/
+ /// </summary>
public void EnableOpenTrackingEmail()
{
var header = new Header();
@@ -129,19 +140,62 @@ namespace Example
message.Html = "<p style='color:red';>Hello World Plain Text</p>";
//set the message subject
- message.Subject = "Hello World Simple Test";
+ message.Subject = "Hello World Open Tracking Test";
//create an instance of the SMTP transport mechanism
- //var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+ var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
//enable gravatar
message.EnableOpenTracking();
Console.WriteLine(header.AsJson());
+ //send the mail
+ smtpInstance.Deliver(message);
+
Console.WriteLine("done");
+ }
+
+ /// <summary>
+ /// Enable the Open Tracking to track when emails are opened.
+ /// http://docs.sendgrid.com/documentation/apps/open-tracking/
+ /// </summary>
+ public void EnableClickTrackingEmail()
+ {
+ var header = new Header();
+ //create a new message object
+ var message = SendGrid.GenerateInstance();
+
+ //set the message recipients
+ foreach (string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
+
+ //set the sender
+ message.From = new MailAddress(_from);
+
+ //set the message body
+ var timestamp = DateTime.Now.ToString("HH:mm:ss tt");
+ message.Html = "<p style='color:red';>Hello World Plain Text</p> <a href = 'http://microsoft.com'>Checkout Microsoft!!</a>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ //set the message subject
+ message.Subject = "Hello World Click Tracking Test";
+
+ //create an instance of the SMTP transport mechanism
+ var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+
+ //enable clicktracking
+ message.EnableClickTracking("1");
+
+ Console.WriteLine(header.AsJson());
+
//send the mail
- //smtpInstance.Deliver(message);
+ smtpInstance.Deliver(message);
+
+ Console.WriteLine("done");
+ Console.WriteLine("Sent at : "+timestamp);
}
}