Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EmailService : IIdentityMessageService
- {
- public async Task SendAsync(IdentityMessage message)
- {
- // Plug in your email service here to send an email.
- var email =
- new MailMessage(new MailAddress("donotreply@bugtracker.com", "(do not reply)"),
- new MailAddress(message.Destination))
- {
- Subject = message.Subject,
- Body = message.Body,
- IsBodyHtml = true
- };
- var GmailUsername = WebConfigurationManager.AppSettings["username"];
- var GmailPassword = WebConfigurationManager.AppSettings["password"];
- var host = WebConfigurationManager.AppSettings["host"];
- int port = Convert.ToInt32(WebConfigurationManager.AppSettings["port"]);
- using (var smtp = new SmtpClient()
- {
- Host = host,
- Port = port,
- EnableSsl = true,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- UseDefaultCredentials = false,
- Credentials = new NetworkCredential(GmailUsername, GmailPassword)
- })
- {
- try
- {
- await smtp.SendMailAsync(email);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- await Task.FromResult(0);
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement