Last active
May 29, 2019 13:20
-
-
Save nesticle8bit/a1bb7a4ffcfaee55e338bf26597c9370 to your computer and use it in GitHub Desktop.
Enviar correos electronicos
This file contains 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
public class EmailService : IIdentityMessageService | |
{ | |
public Task SendAsync(IdentityMessage message) | |
{ | |
var credentialUserName = ConfigurationManager.AppSettings.Get("IPS.Email.Email"); | |
var sentFrom = credentialUserName; | |
var pwd = ConfigurationManager.AppSettings.Get("IPS.Email.Password"); | |
SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings.Get("IPS.Email.SMTP")) | |
{ | |
Port = Convert.ToInt32(ConfigurationManager.AppSettings.Get("IPS.Email.Port")), | |
DeliveryMethod = SmtpDeliveryMethod.Network, | |
UseDefaultCredentials = false | |
}; | |
NetworkCredential credentials = new NetworkCredential(credentialUserName, pwd); | |
client.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("IPS.Email.SSL")); | |
client.Credentials = credentials; | |
MailMessage mail = new MailMessage(sentFrom, message.Destination) | |
{ | |
Subject = message.Subject, | |
Body = message.Body, | |
IsBodyHtml = true | |
}; | |
return client.SendMailAsync(mail); | |
} | |
} |
This file contains 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
<add key="IPS.Email.Email" value="" /> | |
<add key="IPS.Email.Password" value="" /> | |
<add key="IPS.Email.SMTP" value="smtp.gmail.com" /> | |
<add key="IPS.Email.Port" value="587" /> | |
<add key="IPS.Email.SSL" value="true" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment