Created
April 18, 2018 10:05
-
-
Save rudiv/3300025ec5b816ea67bea7469f74e022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.net> | |
<mailSettings> | |
<smtp from="[email protected]"> | |
<network host="smtp.sendgrid.net" userName="u@d" password="p" /> | |
</smtp> | |
</mailSettings> | |
</system.net> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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