I'm creating a messaging application that will use an outlook account to send an email. However, I'm unsure about the proper steps to store the e-mail password on the user's computer. Suppose I had the following code:
SmtpClient SmtpServer = new SmtpClient("smtp.example.com"); var mail = new MailMessage(); mail.From = new MailAddress("email@example.com"); mail.To.Add("firstname.lastname@example.org"); mail.Subject = "Test Mail - 1"; mail.IsBodyHtml = true; string htmlBody; htmlBody = "Write some HTML code here"; mail.Body = htmlBody; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("email@example.com","pass"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail);
Obviously, I don't want "password" stored as a string inside my application. What would be the ideal/proper solution to storing a password on the user's machine so I can read it into my application, and pass it to the NetworkCredential constructor?
This may have been a bit unclear from the above, but I want to allow some person, for which I set up an Outlook account, to send mails to other persons. So one may interpret this in that way that the created account "belongs" to that person, but I also know the password - for administration purposes and the user may know it.