diff options
Diffstat (limited to 'SendGrid/Example/SMTPAPI.cs')
-rwxr-xr-x | SendGrid/Example/SMTPAPI.cs | 70 |
1 files changed, 62 insertions, 8 deletions
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);
}
}
|