diff options
Diffstat (limited to 'SendGrid/Example/SMTPAPI.cs')
-rwxr-xr-x | SendGrid/Example/SMTPAPI.cs | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/SendGrid/Example/SMTPAPI.cs b/SendGrid/Example/SMTPAPI.cs index f4a48db..6ed10cb 100755 --- a/SendGrid/Example/SMTPAPI.cs +++ b/SendGrid/Example/SMTPAPI.cs @@ -28,10 +28,13 @@ namespace Example var message = new SendGrid(new Header());
//set the message recipients
- message.AddTo("cj.buchmann@sendgrid.com");
+ foreach(string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
//set the sender
- message.From = new MailAddress("eric@sendgrid.com");
+ message.From = new MailAddress(_from);
//set the message body
message.Html = "<html><p>Hello</p><p>World</p></html>";
@@ -52,10 +55,13 @@ namespace Example var message = new SendGrid(new Header());
//set the message recipients
- message.AddTo("cj.buchmann@sendgrid.com");
+ foreach(string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
//set the sender
- message.From = new MailAddress("eric@sendgrid.com");
+ message.From = new MailAddress(_from);
//set the message body
message.Text = "Hello World Plain Text";
@@ -77,19 +83,22 @@ namespace Example var message = new SendGrid(header);
//set the message recipients
- message.AddTo("cj.buchmann@sendgrid.com");
+ foreach (string recipient in _to)
+ {
+ message.AddTo(recipient);
+ }
//set the sender
- message.From = new MailAddress("cj.buchmann@sendgrid.com");
+ message.From = new MailAddress(_from);
//set the message body
- message.Html = "<p style='color:red';>Hello World Plain Text</p>";
+ message.Html = "<p style='color:red';>Hello World Gravatar Email</p>";
//set the message subject
message.Subject = "Hello World Simple 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.EnableGravatar();
@@ -98,6 +107,40 @@ namespace Example Console.WriteLine("done");
//send the mail
+ smtpInstance.Deliver(message);
+ }
+
+ public void EnableOpenTrackingEmail()
+ {
+ var header = new Header();
+ //create a new message object
+ var message = new SendGrid(header);
+
+ //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 = "<p style='color:red';>Hello World Plain Text</p>";
+
+ //set the message subject
+ message.Subject = "Hello World Simple Test";
+
+ //create an instance of the SMTP transport mechanism
+ //var smtpInstance = SMTP.GenerateInstance(new NetworkCredential(_username, _password));
+
+ //enable gravatar
+ message.EnableOpenTracking();
+
+ Console.WriteLine(header.AsJson());
+
+ Console.WriteLine("done");
+ //send the mail
//smtpInstance.Deliver(message);
}
|