Is there a way to hide the password using SmtpClient
object?
I would like avoid to hard-code my password in a class or in the web.config
.
using (var smtp = new SmtpClient())
{
var credential = new NetworkCredential
{
UserName = "user@outlook.com", // replace with valid value
Password = "password" // replace with valid value
};
smtp.Credentials = credential;
smtp.Host = "smtp-mail.outlook.com";
smtp.Port = 587;
smtp.EnableSsl = true;
await smtp.SendMailAsync(message);
return RedirectToAction("Sent");
}