Skip to content

Instantly share code, notes, and snippets.

@brandonmwest
Created October 11, 2013 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonmwest/6937700 to your computer and use it in GitHub Desktop.
Save brandonmwest/6937700 to your computer and use it in GitHub Desktop.
Send an email with categories using sendgrid-csharp
// Create the email object first, then add the properties.
SendGrid myMessage = SendGrid.GetInstance();
myMessage.AddTo("anna@example.com");
myMessage.From = new MailAddress("john@example.com", "John Smith");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World!";
string[] categories = new string[3] {"category1", "category2", "category3"};
myMessage.SetCategories(categories);
// Create credentials, specifying your user name and password.
var credentials = new NetworkCredential("username", "password");
// Create an SMTP transport for sending email.
var transportSMTP = SMTP.GetInstance(credentials);
// Send the email.
transportSMTP.Deliver(myMessage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment