Skip to content

Instantly share code, notes, and snippets.

@jd-alexander
Created June 27, 2016 22:19
Show Gist options
  • Save jd-alexander/5c82f149ad3e8f5b73294e5a9d0aaa69 to your computer and use it in GitHub Desktop.
Save jd-alexander/5c82f149ad3e8f5b73294e5a9d0aaa69 to your computer and use it in GitHub Desktop.
private async Task ConfigSendGridasync(IdentityMessage message)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var myMessage = new SendGridMessage();
var result = PreMailer.Net.PreMailer.MoveCssInline(message.Body);
myMessage.AddTo(message.Destination);
myMessage.From = new System.Net.Mail.MailAddress("admin@carefulaccess.com", "Careful Access");
myMessage.Subject = message.Subject;
myMessage.Text = result.Html;
myMessage.Html = result.Html;
var credentials = new NetworkCredential(username,password);
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
await transportWeb.DeliverAsync(myMessage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment