Skip to content

Instantly share code, notes, and snippets.

@rudiv
Created April 18, 2018 10:05
Show Gist options
  • Save rudiv/3300025ec5b816ea67bea7469f74e022 to your computer and use it in GitHub Desktop.
Save rudiv/3300025ec5b816ea67bea7469f74e022 to your computer and use it in GitHub Desktop.
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.sendgrid.net" userName="u@d" password="p" />
</smtp>
</mailSettings>
</system.net>
using System.Net.Mail;
// ..
private async Task configSendGridasync(IdentityMessage message)
{
var myMessage = new MailMessage();
myMessage.To.Add(new MailAddress(message.Destination));
myMessage.From = new MailAddress("[email protected]", "test Support");
myMessage.Subject = message.Subject;
myMessage.IsBodyHtml = true;
myMessage.Body = message.Body;
var smtpClient = new SmtpClient();
try
{
await smtpClient.SendMailAsync(myMessage);
} catch(Exception ex)
{
Trace.TraceError(ex.Message + " SendGrid probably not configured correctly.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment