diff options
author | CJ Buchmann <cj.buchmann@sendgrid.com> | 2012-01-12 16:08:13 -0800 |
---|---|---|
committer | CJ Buchmann <cj.buchmann@sendgrid.com> | 2012-01-12 16:08:13 -0800 |
commit | 48068853163d337f34cd1f971361d6caf97bd7a7 (patch) | |
tree | 4743befca3f7cc2cf6ed4f9f5395fd9c9c8f3c94 /SendGrid/Example/SMTPAPI.cs | |
parent | d80dbc622a49ce07b7d2a8a43e275d59550202c3 (diff) | |
download | sendgrid-csharp-48068853163d337f34cd1f971361d6caf97bd7a7.zip sendgrid-csharp-48068853163d337f34cd1f971361d6caf97bd7a7.tar.gz sendgrid-csharp-48068853163d337f34cd1f971361d6caf97bd7a7.tar.bz2 |
Added support for Rest API, to get mailing working. Also added examples to send a simple web api.
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);
}
|