summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xSendGrid/Example/Program.cs58
-rwxr-xr-xSendGrid/Example/RESTAPI.cs406
-rwxr-xr-xSendGrid/Example/SMTPAPI.cs291
-rwxr-xr-xSendGrid/SendGridMail/ISendGrid.cs13
-rwxr-xr-xSendGrid/SendGridMail/Mail.csproj8
-rwxr-xr-xSendGrid/SendGridMail/Mail.nuspec15
-rwxr-xr-xSendGrid/SendGridMail/Properties/AssemblyInfo.cs1
-rwxr-xr-xSendGrid/SendGridMail/SendGrid.cs23
-rwxr-xr-xSendGrid/SendGridMail/Sendgrid.1.0.0.nupkgbin0 -> 34686 bytes
-rwxr-xr-xSendGrid/SendGridMail/Transport/ITransport.cs5
-rwxr-xr-xSendGrid/SendGridMail/Transport/REST.cs9
-rwxr-xr-xSendGrid/SendGridMail/Transport/SMTP.cs4
-rwxr-xr-xSendGrid/SendGridMail/lib/CodeScales.Http.dll (renamed from SendGrid/packages/CodeScales.Http.dll)bin40960 -> 40960 bytes
-rwxr-xr-xSendGrid/Tests/TestSendgrid.cs39
-rwxr-xr-xSendGrid/Tests/Transport/TestREST.cs28
-rwxr-xr-xSendGrid/Tests/Transport/TestSMTP.cs8
16 files changed, 739 insertions, 169 deletions
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs
index 0d558a5..c1815b7 100755
--- a/SendGrid/Example/Program.cs
+++ b/SendGrid/Example/Program.cs
@@ -11,68 +11,26 @@ namespace Example
{
class Program
{
- static void Main(String[] args)
- {
- var restInstance = REST.GetInstance(new NetworkCredential("sgrid_username", "sgrid_password"));
-
- //create a new message object
- var message = SendGrid.GenerateInstance();
-
- message.AddTo("cj.buchmann@sendgrid.com");
- message.AddTo("tyler.bischel@sendgrid.com");
- message.AddTo("kyle.partridge@sendgrid.com");
- message.From = new MailAddress("cj.buchmann@sendgrid.com");
- message.Html = "<div>hello world</div>";
- message.Subject = "Hello World SUbject";
- message.AddAttachment(@"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg");
- message.AddAttachment(@"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg");
- restInstance.Deliver(message);
-
- Console.WriteLine("Message Sent");
- Console.WriteLine("DONE!");
- Console.ReadLine();
- }
-
// this code is used for the SMTPAPI examples
- /*static void Main(string[] args)
+ static void Main(string[] args)
{
- var username = "cjbuchmann";
- var password = "gadget15";
+ var username = "sgrid_username";
+ var password = "sgrid_password";
var from = "cj.buchmann@sendgrid.com";
var to = new List<String>
{
"cj.buchmann@sendgrid.com"
};
- var bcc = new List<string>
- {
- "eric@sendgrid.com"
- };
-
- var cc = new List<string>
- {
- "eric@sendgrid.com"
- };
-
//initialize the SMTPAPI example class
var smtpapi = new SMTPAPI(username, password, from, to);
+ var restapi = new RESTAPI(username, password, from, to);
- //send a simple HTML encoded email.
- //smtpapi.SimpleHTMLEmail();
-
- //send a simple Plaintext email.
- //smtpapi.SimplePlaintextEmail();
-
- //send a gravatar enabled email.
- //smtpapi.EnableGravatarEmail();
-
- //send an open tracking enabled email.
- //smtpapi.EnableOpenTrackingEmail();
-
- //send an open tracking enabled email.
- smtpapi.EnableClickTrackingEmail();
+ //use this section to test out our REST and SMTP examples!
+ restapi.EnableTemplateEmail();
+ Console.WriteLine("Done!");
Console.ReadLine();
- }*/
+ }
}
}
diff --git a/SendGrid/Example/RESTAPI.cs b/SendGrid/Example/RESTAPI.cs
index c90253a..8c15800 100755
--- a/SendGrid/Example/RESTAPI.cs
+++ b/SendGrid/Example/RESTAPI.cs
@@ -14,80 +14,412 @@ namespace Example
private String _password;
private String _from;
private IEnumerable<String> _to;
- private IEnumerable<String> _bcc;
- private IEnumerable<String> _cc;
- public RESTAPI(String username, String password, String from, IEnumerable<String> recipients, IEnumerable<String> bcc, IEnumerable<String> cc)
+ public RESTAPI(String username, String password, String from, IEnumerable<String> recipients)
{
_username = username;
_password = password;
_from = from;
_to = recipients;
- _bcc = bcc;
- _cc = cc;
}
+ /// <summary>
+ /// Send a simple HTML based email
+ /// </summary>
public void SimpleHTMLEmail()
{
//create a new message object
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
//set the message recipients
+ foreach (string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
+
+ //set the sender
+ message.From = new MailAddress(_from);
+
+ //set the message body
+ message.Html = "<html><p>Hello</p><p>World</p></html>";
+
+ //set the message subject
+ message.Subject = "Hello World HTML Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// Send a simple Plain Text email
+ /// </summary>
+ public void SimplePlaintextEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
- if(_to != null)
+ //set the message recipients
+ foreach (string recipient in _to)
{
- foreach (String recipient in _to)
- {
- message.AddTo(recipient);
- }
+ message.AddTo(recipient);
}
+ //set the sender
+ message.From = new MailAddress(_from);
+
+ //set the message body
+ message.Text = "Hello World Plain Text";
+
+ //set the message subject
+ message.Subject = "Hello World Plain Text Test";
- if(_bcc != null)
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// Enable The Gravatar Filter.
+ /// Currently the filter generates a 1x1 pixel gravatar image.
+ /// http://docs.sendgrid.com/documentation/apps/gravatar/
+ /// </summary>
+ public void EnableGravatarEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //set the message recipients
+ foreach (string recipient in _to)
{
- foreach (String blindcc in _bcc)
- {
- message.AddBcc(blindcc);
- }
+ message.AddTo(recipient);
}
-
- if(_cc != null)
+
+ //set the sender
+ message.From = new MailAddress(_from);
+
+ //set the message body
+ message.Html = "<p style='color:red';>Hello World Gravatar Email</p>";
+
+ //set the message subject
+ message.Subject = "Hello World Gravatar Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable gravatar
+ message.EnableGravatar();
+
+ //send the mail
+ transportInstance.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()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //set the message recipients
+ foreach (string recipient in _to)
{
- foreach (String cc in _cc)
- {
- message.AddCc(cc);
- }
+ message.AddTo(recipient);
}
- var headers = new Dictionary<String, String>
- {
- {"key1", "value1"},
- {"key2", "value2"},
- {"icanhazcheeze", "kthnxbye"}
- };
+ //set the sender
+ message.From = new MailAddress(_from);
+
+ //set the message body
+ message.Html = "<p style='color:red';>Hello World Plain Text</p>";
+
+ //set the message subject
+ message.Subject = "Hello World Open Tracking Test";
- message.AddHeaders(headers);
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
- //var replyTo = new List<MailAddress> { new MailAddress("tyler.bischel@sendgrid.com") };
+ //enable gravatar
+ message.EnableOpenTracking();
- //message.ReplyTo = replyTo.ToArray();
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// Point the urls to Sendgrid Servers so that the clicks can be logged before
+ /// being directed to the appropriate link
+ /// http://docs.sendgrid.com/documentation/apps/click-tracking/
+ /// </summary>
+ public void EnableClickTrackingEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //set the message recipients
+ foreach (string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
//set the sender
message.From = new MailAddress(_from);
//set the message body
- message.Html = "<html><p>Hello</p><p>World</p></html>";
+ var timestamp = DateTime.Now.ToString("HH:mm:ss tt");
+ message.Html = "<p style='color:red';>Hello World HTML </p> <a href='http://microsoft.com'>Checkout Microsoft!!</a>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "hello world http://microsoft.com";
+
+ //set the message subject
+ message.Subject = "Hello World Click Tracking Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable clicktracking
+ message.EnableClickTracking(false);
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// The Spam Checker filter, is useful when your web application allows your end users
+ /// to create content that is then emailed through your SendGrid account.
+ /// http://docs.sendgrid.com/documentation/apps/spam-checker-filter/
+ /// </summary>
+ public void EnableSpamCheckEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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';>VIAGRA!!!!!! Viagra!!! CHECKOUT THIS VIAGRA!!!! MALE ENHANCEMENT!!! </p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ //set the message subject
+ message.Subject = "WIN A MILLION DOLLARS TODAY! WORK FROM HOME! A NIGERIAN PRINCE WANTS YOU!";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable spamcheck
+ message.EnableSpamCheck();
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// Add automatic unsubscribe links to the bottom of emails.
+ /// http://docs.sendgrid.com/documentation/apps/subscription-tracking/
+ /// </summary>
+ public void EnableUnsubscribeEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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 = "This is the HTML body";
+
+ message.Text = "This is the plain text body";
+
+ //set the message subject
+ message.Subject = "Hello World Unsubscribe Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable spamcheck
+ //or optionally, you can specify 'replace' instead of the text and html in order to
+ //place the link wherever you want.
+ message.EnableUnsubscribe("Please click the following link to unsubscribe: <% %>", "Please click <% here %> to unsubscribe");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// The Footer App will insert a custom footer at the bottom of the text and HTML bodies.
+ /// http://docs.sendgrid.com/documentation/apps/footer/
+ /// </summary>
+ public void EnableFooterEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Footer Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //Enable Footer
+ message.EnableFooter("PLAIN TEXT FOOTER", "<p color='blue'>HTML FOOTER TEXT</p>");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// The Footer App will insert a custom footer at the bottom of the text and HTML bodies.
+ /// http://docs.sendgrid.com/documentation/apps/google-analytics/
+ /// </summary>
+ public void EnableGoogleAnalytics()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+ message.Html += "Checkout my page at <a href=\"http://microsoft.com\">Microsoft</a>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Footer Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable Google Analytics
+ message.EnableGoogleAnalytics("SendGridTest", "EMAIL", "Sendgrid", "ad-one", "My SG Campaign");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// This feature wraps an HTML template around your email content.
+ /// This can be useful for sending out newsletters and/or other HTML formatted messages.
+ /// http://docs.sendgrid.com/documentation/apps/email-templates/
+ /// </summary>
+ public void EnableTemplateEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Template Test";
+
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable template
+ message.EnableTemplate("<p>My Email Template <% body %> is awesome!</p>");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// This feature wraps an HTML template around your email content.
+ /// This can be useful for sending out newsletters and/or other HTML formatted messages.
+ /// hhttp://docs.sendgrid.com/documentation/apps/email-templates/
+ /// </summary>
+ public void EnableBypassListManagementEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "Hello World plain text";
//set the message subject
- message.Subject = "Hello World Simple Test";
+ message.Subject = "Hello World Bypass List Management Test";
- message.AddAttachment(@"D:\att_proj\21.jpg");
+ //create an instance of the REST transport mechanism
+ var transportInstance = REST.GetInstance(new NetworkCredential(_username, _password));
- //create an instance of the SMTP transport mechanism
- var restInstance = REST.GetInstance(new NetworkCredential(_username, _password));
+ //enable bypass list management
+ message.EnableBypassListManagement();
//send the mail
- restInstance.Deliver(message);
+ transportInstance.Deliver(message);
}
}
}
diff --git a/SendGrid/Example/SMTPAPI.cs b/SendGrid/Example/SMTPAPI.cs
index 4e43672..ca80f69 100755
--- a/SendGrid/Example/SMTPAPI.cs
+++ b/SendGrid/Example/SMTPAPI.cs
@@ -12,9 +12,9 @@ namespace Example
private String _username;
private String _password;
private String _from;
- private IEnumerable<string> _to;
+ private IEnumerable<String> _to;
- public SMTPAPI(String username, String password, String from, IEnumerable<string> recipients)
+ public SMTPAPI(String username, String password, String from, IEnumerable<String> recipients)
{
_username = username;
_password = password;
@@ -28,7 +28,7 @@ namespace Example
public void SimpleHTMLEmail()
{
//create a new message object
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
//set the message recipients
foreach(string recipient in _to)
@@ -43,13 +43,13 @@ namespace Example
message.Html = "<html><p>Hello</p><p>World</p></html>";
//set the message subject
- message.Subject = "Hello World Simple Test";
+ message.Subject = "Hello World HTML Test";
//create an instance of the SMTP transport mechanism
- var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
//send the mail
- smtpInstance.Deliver(message);
+ transportInstance.Deliver(message);
}
/// <summary>
@@ -58,7 +58,7 @@ namespace Example
public void SimplePlaintextEmail()
{
//create a new message object
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
//set the message recipients
foreach(string recipient in _to)
@@ -73,24 +73,24 @@ namespace Example
message.Text = "Hello World Plain Text";
//set the message subject
- message.Subject = "Hello World Simple Test";
+ message.Subject = "Hello World Plain Text Test";
//create an instance of the SMTP transport mechanism
- var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
//send the mail
- smtpInstance.Deliver(message);
+ transportInstance.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/
+ /// Currently the filter generates a 1x1 pixel gravatar image.
+ /// http://docs.sendgrid.com/documentation/apps/gravatar/
/// </summary>
public void EnableGravatarEmail()
{
//create a new message object
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
//set the message recipients
foreach (string recipient in _to)
@@ -108,13 +108,13 @@ namespace Example
message.Subject = "Hello World Gravatar Test";
//create an instance of the SMTP transport mechanism
- var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
//enable gravatar
message.EnableGravatar();
//send the mail
- smtpInstance.Deliver(message);
+ transportInstance.Deliver(message);
}
/// <summary>
@@ -123,9 +123,8 @@ namespace Example
/// </summary>
public void EnableOpenTrackingEmail()
{
- var header = new Header();
//create a new message object
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
//set the message recipients
foreach (string recipient in _to)
@@ -143,28 +142,24 @@ namespace Example
message.Subject = "Hello World Open Tracking Test";
//create an instance of the SMTP transport mechanism
- var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
//enable gravatar
message.EnableOpenTracking();
- Console.WriteLine(header.AsJson());
-
//send the mail
- smtpInstance.Deliver(message);
-
- Console.WriteLine("done");
+ transportInstance.Deliver(message);
}
/// <summary>
- /// Enable the Open Tracking to track when emails are opened.
- /// http://docs.sendgrid.com/documentation/apps/open-tracking/
+ /// Point the urls to Sendgrid Servers so that the clicks can be logged before
+ /// being directed to the appropriate link
+ /// http://docs.sendgrid.com/documentation/apps/click-tracking/
/// </summary>
public void EnableClickTrackingEmail()
{
- var header = new Header();
//create a new message object
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
//set the message recipients
foreach (string recipient in _to)
@@ -177,25 +172,253 @@ namespace Example
//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 style='color:red';>Hello World HTML </p> <a href='http://microsoft.com'>Checkout Microsoft!!</a>";
message.Html += "<p>Sent At : " + timestamp + "</p>";
+ message.Text = "hello world http://microsoft.com";
+
//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));
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
//enable clicktracking
- message.EnableClickTracking(true);
+ message.EnableClickTracking(false);
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// The Spam Checker filter, is useful when your web application allows your end users
+ /// to create content that is then emailed through your SendGrid account.
+ /// http://docs.sendgrid.com/documentation/apps/spam-checker-filter/
+ /// </summary>
+ public void EnableSpamCheckEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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';>VIAGRA!!!!!! Viagra!!! CHECKOUT THIS VIAGRA!!!! MALE ENHANCEMENT!!! </p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ //set the message subject
+ message.Subject = "WIN A MILLION DOLLARS TODAY! WORK FROM HOME! A NIGERIAN PRINCE WANTS YOU!";
+
+ //create an instance of the SMTP transport mechanism
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable spamcheck
+ message.EnableSpamCheck();
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// Add automatic unsubscribe links to the bottom of emails.
+ /// http://docs.sendgrid.com/documentation/apps/subscription-tracking/
+ /// </summary>
+ public void EnableUnsubscribeEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //set the message recipients
+ foreach (string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
- Console.WriteLine(header.AsJson());
+ //set the sender
+ message.From = new MailAddress(_from);
+
+ //set the message body
+ var timestamp = DateTime.Now.ToString("HH:mm:ss tt");
+ message.Html = "This is the HTML body";
+
+ message.Text = "This is the plain text body";
+
+ //set the message subject
+ message.Subject = "Hello World Unsubscribe Test";
+
+ //create an instance of the SMTP transport mechanism
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable spamcheck
+ //or optionally, you can specify 'replace' instead of the text and html in order to
+ //place the link wherever you want.
+ message.EnableUnsubscribe("Please click the following link to unsubscribe: <% %>", "Please click <% here %> to unsubscribe");
//send the mail
- smtpInstance.Deliver(message);
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// The Footer App will insert a custom footer at the bottom of the text and HTML bodies.
+ /// http://docs.sendgrid.com/documentation/apps/footer/
+ /// </summary>
+ public void EnableFooterEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
- Console.WriteLine("done");
- Console.WriteLine("Sent at : "+timestamp);
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Footer Test";
+
+ //create an instance of the SMTP transport mechanism
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
+
+ //Enable Footer
+ message.EnableFooter("PLAIN TEXT FOOTER", "<p color='blue'>HTML FOOTER TEXT</p>");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// The Footer App will insert a custom footer at the bottom of the text and HTML bodies.
+ /// http://docs.sendgrid.com/documentation/apps/google-analytics/
+ /// </summary>
+ public void EnableGoogleAnalytics()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+ message.Html += "Checkout my page at <a href=\"http://microsoft.com\">Microsoft</a>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Footer Test";
+
+ //create an instance of the SMTP transport mechanism
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable Google Analytics
+ message.EnableGoogleAnalytics("SendGridTest", "EMAIL", "Sendgrid", "ad-one", "My SG Campaign");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// This feature wraps an HTML template around your email content.
+ /// This can be useful for sending out newsletters and/or other HTML formatted messages.
+ /// http://docs.sendgrid.com/documentation/apps/email-templates/
+ /// </summary>
+ public void EnableTemplateEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Template Test";
+
+ //create an instance of the SMTP transport mechanism
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable template
+ message.EnableTemplate("<p>My Email Template <% body %> is awesome!</p>");
+
+ //send the mail
+ transportInstance.Deliver(message);
+ }
+
+ /// <summary>
+ /// This feature wraps an HTML template around your email content.
+ /// This can be useful for sending out newsletters and/or other HTML formatted messages.
+ /// hhttp://docs.sendgrid.com/documentation/apps/email-templates/
+ /// </summary>
+ public void EnableBypassListManagementEmail()
+ {
+ //create a new message object
+ var message = SendGrid.GetInstance();
+
+ //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</p>";
+ message.Html += "<p>Sent At : " + timestamp + "</p>";
+
+ message.Text = "Hello World plain text";
+
+ //set the message subject
+ message.Subject = "Hello World Bypass List Management Test";
+
+ //create an instance of the SMTP transport mechanism
+ var transportInstance = SMTP.GetInstance(new NetworkCredential(_username, _password));
+
+ //enable bypass list management
+ message.EnableBypassListManagement();
+
+ //send the mail
+ transportInstance.Deliver(message);
}
}
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs
index 3be707f..08d109c 100755
--- a/SendGrid/SendGridMail/ISendGrid.cs
+++ b/SendGrid/SendGridMail/ISendGrid.cs
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
-using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Mail;
-using System.Net.Mime;
-using System.Text;
namespace SendGridMail
{
@@ -219,10 +215,13 @@ namespace SendGridMail
/// </summary>
/// <param name="text">String for the plain text email body showing what you want the message to look like.</param>
/// <param name="html">String for the HTML email body showing what you want the message to look like.</param>
+ void EnableUnsubscribe(String text, String html);
+
+ /// <summary>
+ /// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
+ /// </summary>
/// <param name="replace">Tag in the message body to be replaced with the unsubscribe link and message</param>
- /// <param name="url">URL for a landing page, if you have your own prepared</param>
- /// <param name="landing">HTML body of a landing page created by SendGrid for you</param>
- void EnableUnsubscribe(String text, String html, String replace, String url, String landing);
+ void EnableUnsubscribe(String replace);
/// <summary>
/// Attaches a message at the footer of the email
diff --git a/SendGrid/SendGridMail/Mail.csproj b/SendGrid/SendGridMail/Mail.csproj
index d652771..bd1dc7a 100755
--- a/SendGrid/SendGridMail/Mail.csproj
+++ b/SendGrid/SendGridMail/Mail.csproj
@@ -31,8 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="CodeScales.Http">
- <HintPath>..\packages\CodeScales.Http.dll</HintPath>
+ <Reference Include="CodeScales.Http, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\CodeScales.Http.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -57,6 +58,9 @@
<Compile Include="Transport\SMTP.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="lib\CodeScales.Http.dll" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/SendGrid/SendGridMail/Mail.nuspec b/SendGrid/SendGridMail/Mail.nuspec
new file mode 100755
index 0000000..39d44bf
--- /dev/null
+++ b/SendGrid/SendGridMail/Mail.nuspec
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>Sendgrid</id>
+ <version>1.0.0</version>
+ <title>Sendgrid</title>
+ <authors>CJ Buchmann, Tyler Bischel, Eric Becking</authors>
+ <owners>Sendgrid</owners>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>$description$</description>
+ <releaseNotes>Basic C# client library and examples for using Sendgrid API's to send mail</releaseNotes>
+ <copyright>Copyright 2012</copyright>
+ <tags>Sendgrid Email Mail Microsoft Azure</tags>
+ </metadata>
+</package> \ No newline at end of file
diff --git a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs
index 310fe3b..e6e890f 100755
--- a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs
+++ b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs
@@ -5,7 +5,6 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-
[assembly: AssemblyTitle("SendGridMail")]
[assembly: AssemblyDescription("A client library for interfacing with the SendGrid API")]
[assembly: AssemblyConfiguration("")]
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs
index 4b91dfc..59d7976 100755
--- a/SendGrid/SendGridMail/SendGrid.cs
+++ b/SendGrid/SendGridMail/SendGrid.cs
@@ -30,7 +30,7 @@ namespace SendGridMail
/// Creates an instance of SendGrid's custom message object
/// </summary>
/// <returns></returns>
- public static SendGrid GenerateInstance()
+ public static SendGrid GetInstance()
{
var header = new Header();
return new SendGrid(header);
@@ -48,7 +48,7 @@ namespace SendGridMail
/// <param name="text">the plain text part of the message</param>
/// <param name="transport">Transport class to use for sending the message</param>
/// <returns></returns>
- public static SendGrid GenerateInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
+ public static SendGrid GetInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
String subject, String html, String text, TransportType transport)
{
var header = new Header();
@@ -394,7 +394,7 @@ namespace SendGridMail
Header.AddFilterSetting(filter, new List<string> { "url" }, url);
}
- public void EnableUnsubscribe(string text, string html, string replace, string url, string landing)
+ public void EnableUnsubscribe(string text, string html)
{
var filter = _filters["Unsubscribe"];
@@ -410,10 +410,15 @@ namespace SendGridMail
Header.Enable(filter);
Header.AddFilterSetting(filter, new List<string> { "text/plain" }, text);
- Header.AddFilterSetting(filter, new List<string> { "text/html" }, html);
- Header.AddFilterSetting(filter, new List<string> { "replace"}, replace);
- Header.AddFilterSetting(filter, new List<string> { "url"}, url);
- Header.AddFilterSetting(filter, new List<string> { "landing" }, landing);
+ Header.AddFilterSetting(filter, new List<string> {"text/html"}, html);
+ }
+
+ public void EnableUnsubscribe(string replace)
+ {
+ var filter = _filters["Unsubscribe"];
+
+ Header.Enable(filter);
+ Header.AddFilterSetting(filter, new List<string> { "replace" }, replace);
}
public void EnableFooter(string text = null, string html = null)
@@ -506,7 +511,7 @@ namespace SendGridMail
/// Helper function lets us look at the mime before it is sent
/// </summary>
/// <param name="directory">directory in which we store this mime message</param>
- internal void SaveMessage(String directory)
+ public void SaveMessage(String directory)
{
var client = new SmtpClient("localhost")
{
@@ -523,7 +528,7 @@ namespace SendGridMail
switch (Transport)
{
case TransportType.SMTP:
- transport = SMTP.GenerateInstance(credentials);
+ transport = SMTP.GetInstance(credentials);
break;
case TransportType.REST:
transport = REST.GetInstance(credentials);
diff --git a/SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg b/SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg
new file mode 100755
index 0000000..aeaf84e
--- /dev/null
+++ b/SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg
Binary files differ
diff --git a/SendGrid/SendGridMail/Transport/ITransport.cs b/SendGrid/SendGridMail/Transport/ITransport.cs
index 26fccf4..b3a1936 100755
--- a/SendGrid/SendGridMail/Transport/ITransport.cs
+++ b/SendGrid/SendGridMail/Transport/ITransport.cs
@@ -1,7 +1,8 @@
namespace SendGridMail.Transport
{
/// <summary>
- ///
+ /// Encapsulates the transport mechanism so that it can be used in a generic way,
+ /// regardless of the transport type
/// </summary>
public interface ITransport
{
@@ -11,4 +12,4 @@
/// <param name="message">the message to be delivered</param>
void Deliver(ISendGrid message);
}
-}
+} \ No newline at end of file
diff --git a/SendGrid/SendGridMail/Transport/REST.cs b/SendGrid/SendGridMail/Transport/REST.cs
index 7b8c361..614e024 100755
--- a/SendGrid/SendGridMail/Transport/REST.cs
+++ b/SendGrid/SendGridMail/Transport/REST.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
@@ -20,9 +19,7 @@ namespace SendGridMail.Transport
public const String JsonFormat = "json";
public const String XmlFormat = "xml";
- private readonly List<KeyValuePair<String, String>> _query;
private readonly NetworkCredential _credentials;
- private readonly NameValueCollection _queryParameters;
private readonly String _restEndpoint;
private readonly String _format;
#endregion
@@ -69,7 +66,7 @@ namespace SendGridMail.Transport
#region Support Methods
- private HttpClient InitializeTransport(out MultipartEntity multipartEntity, out HttpPost postMethod)
+ internal HttpClient InitializeTransport(out MultipartEntity multipartEntity, out HttpPost postMethod)
{
var client = new HttpClient();
postMethod = new HttpPost(new Uri(_restEndpoint));
@@ -118,7 +115,7 @@ namespace SendGridMail.Transport
}
}
- private List<KeyValuePair<String, String>> FetchFormParams(ISendGrid message)
+ internal List<KeyValuePair<String, String>> FetchFormParams(ISendGrid message)
{
var result = new List<KeyValuePair<string, string>>()
{
@@ -152,7 +149,7 @@ namespace SendGridMail.Transport
return result.Where(r => !String.IsNullOrEmpty(r.Value)).ToList();
}
- private List<KeyValuePair<String, FileInfo>> FetchFileBodies(ISendGrid message)
+ internal List<KeyValuePair<String, FileInfo>> FetchFileBodies(ISendGrid message)
{
if(message.Attachments == null)
return new List<KeyValuePair<string, FileInfo>>();
diff --git a/SendGrid/SendGridMail/Transport/SMTP.cs b/SendGrid/SendGridMail/Transport/SMTP.cs
index 606afcd..a878ce8 100755
--- a/SendGrid/SendGridMail/Transport/SMTP.cs
+++ b/SendGrid/SendGridMail/Transport/SMTP.cs
@@ -72,7 +72,7 @@ namespace SendGridMail.Transport
/// <param name="credentials">Sendgrid user credentials</param>
/// <param name="host">MTA recieving this message. By default, sent through SendGrid.</param>
/// <param name="port">SMTP port 25 is the default. Port 465 can be used for Secure SMTP.</param>
- public static SMTP GenerateInstance(NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
+ public static SMTP GetInstance(NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
{
var client = new SmtpWrapper(host, port, credentials, SmtpDeliveryMethod.Network);
return new SMTP(client, credentials, host, port);
@@ -86,7 +86,7 @@ namespace SendGridMail.Transport
/// <param name="host"></param>
/// <param name="port"></param>
/// <returns></returns>
- internal static SMTP GenerateInstance(ISmtpClient client, NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
+ internal static SMTP GetInstance(ISmtpClient client, NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
{
return new SMTP(client, credentials, host, port);
}
diff --git a/SendGrid/packages/CodeScales.Http.dll b/SendGrid/SendGridMail/lib/CodeScales.Http.dll
index 2509b52..2509b52 100755
--- a/SendGrid/packages/CodeScales.Http.dll
+++ b/SendGrid/SendGridMail/lib/CodeScales.Http.dll
Binary files differ
diff --git a/SendGrid/Tests/TestSendgrid.cs b/SendGrid/Tests/TestSendgrid.cs
index 71160dc..95604d3 100755
--- a/SendGrid/Tests/TestSendgrid.cs
+++ b/SendGrid/Tests/TestSendgrid.cs
@@ -191,20 +191,34 @@ namespace Tests
var text = "<% %>";
var html = "<% name %>";
- var replace = "John";
- var url = "http://www.example.com";
- var landing = "this_landing";
- sendgrid.EnableUnsubscribe(text, html, replace, url, landing);
- var jsonText = "\"text\\/plain\" : \""+text+"\"";
- var jsonHtml = "\"text\\/html\" : \""+html+"\"";
- var jsonReplace = "\"replace\" : \""+replace+"\"";
- var jsonUrl = "\"url\" : \"http:\\/\\/www.example.com\"";
- var jsonLanding = "\"landing\" : \""+landing+"\"";
+ var jsonText = "\"text\\/plain\" : \"" + text + "\"";
+ var jsonHtml = "\"text\\/html\" : \"" + html + "\"";
+
+ sendgrid.EnableUnsubscribe(text, html);
String json = header.AsJson();
Assert.AreEqual("{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"1\","+
- jsonText+","+jsonHtml+","+jsonReplace+","+jsonUrl+","+jsonLanding+"}}}}", json);
+ jsonText+","+jsonHtml+"}}}}", json);
+
+ header = new Header();
+ sendgrid = new SendGrid(header);
+
+ var replace = "John";
+ var jsonReplace = "\"replace\" : \"" + replace + "\"";
+
+ sendgrid.EnableUnsubscribe(replace);
+
+ json = header.AsJson();
+ Assert.AreEqual("{\"filters\" : {\"subscriptiontrack\" : {\"settings\" : {\"enable\" : \"1\"," + jsonReplace + "}}}}", json);
+
+ text = "bad";
+ html = "<% name %>";
+ Assert.Throws<Exception>(delegate { sendgrid.EnableUnsubscribe(text, html); });
+
+ text = "<% %>";
+ html = "bad";
+ Assert.Throws<Exception>(delegate { sendgrid.EnableUnsubscribe(text, html); });
}
@@ -261,6 +275,9 @@ namespace Tests
String json = header.AsJson();
Assert.AreEqual("{\"filters\" : {\"template\" : {\"settings\" : {\"enable\" : \"1\",\"text\\/html\" : \""+escHtml+"\"}}}}", json);
+
+ escHtml = "bad";
+ Assert.Throws<Exception>(delegate { sendgrid.EnableTemplate(escHtml); });
}
[Test]
@@ -291,7 +308,7 @@ namespace Tests
[Test]
public void CreateMimeMessage()
{
- var message = SendGrid.GenerateInstance();
+ var message = SendGrid.GetInstance();
var attachment = System.IO.Path.GetTempFileName();
var text = "this is a test";
var html = "<b>This<\b> is a better test";
diff --git a/SendGrid/Tests/Transport/TestREST.cs b/SendGrid/Tests/Transport/TestREST.cs
index ccbab48..15c31ed 100755
--- a/SendGrid/Tests/Transport/TestREST.cs
+++ b/SendGrid/Tests/Transport/TestREST.cs
@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Text;
+using Moq;
using NUnit.Framework;
+using SendGridMail;
+using SendGridMail.Transport;
namespace Tests.Transport
{
@@ -10,15 +14,31 @@ namespace Tests.Transport
class TestREST
{
[Test]
- public void TestDeliver()
+ public void TestFetchFileBodies()
{
-
+ var test = REST.GetInstance(new NetworkCredential("foo", "bar"));
+ var message = new Mock<ISendGrid>();
+ message.SetupProperty(foo => foo.Attachments, null);
+ var result = test.FetchFileBodies(message.Object);
+ Assert.AreEqual(0, result.Count);
+
+ message.SetupProperty(foo => foo.Attachments, new string[] {"foo", "bar", "raz"});
+ result = test.FetchFileBodies(message.Object);
+ Assert.AreEqual(3, result.Count);
+ }
+
+ [Test]
+ public void TestFetchFormParams()
+ {
+ var bar = REST.GetInstance(new NetworkCredential("foo", "bar"));
+ //bar.FetchFormParams();
}
[Test]
- public void TestConstructor()
+ public void TestInitializeTransport()
{
-
+ var bar = REST.GetInstance(new NetworkCredential("foo", "bar"));
+ //bar.InitializeTransport();
}
}
}
diff --git a/SendGrid/Tests/Transport/TestSMTP.cs b/SendGrid/Tests/Transport/TestSMTP.cs
index e0e4fe5..3c17008 100755
--- a/SendGrid/Tests/Transport/TestSMTP.cs
+++ b/SendGrid/Tests/Transport/TestSMTP.cs
@@ -23,7 +23,7 @@ namespace Tests.Transport
mockClient.Setup(foo => foo.Send(mime));
var client = mockClient.Object;
var credentials = new NetworkCredential("username", "password");
- var test = SMTP.GenerateInstance(client, credentials);
+ var test = SMTP.GetInstance(client, credentials);
test.Deliver(message);
mockClient.Verify(foo => foo.Send(mime), Times.Once());
@@ -38,14 +38,14 @@ namespace Tests.Transport
mock.SetupProperty(foo => foo.EnableSsl);
var client = mock.Object;
var credentials = new NetworkCredential("username", "password");
- var test = SMTP.GenerateInstance(client, credentials);
+ var test = SMTP.GetInstance(client, credentials);
mock.Verify(foo => foo.EnableSsl, Times.Never());
mock = new Mock<SMTP.ISmtpClient>();
mock.SetupProperty(foo => foo.EnableSsl);
client = mock.Object;
credentials = new NetworkCredential("username", "password");
- test = SMTP.GenerateInstance(client, credentials, port:SMTP.SslPort);
+ test = SMTP.GetInstance(client, credentials, port:SMTP.SslPort);
mock.VerifySet(foo => foo.EnableSsl = true);
mock = new Mock<SMTP.ISmtpClient>();
@@ -54,7 +54,7 @@ namespace Tests.Transport
credentials = new NetworkCredential("username", "password");
try
{
- test = SMTP.GenerateInstance(client, credentials, port: SMTP.TlsPort);
+ test = SMTP.GetInstance(client, credentials, port: SMTP.TlsPort);
Assert.Fail("should have thrown an unsupported port exception");
}
catch (NotSupportedException ex)