How can I make this code send a new generated password or the user its old password?
I figured out how to let the code send a email! The sender is not the problem but the receiver is. Where EmailAdresNaar
must be replaced with an email that someone puts into a text box or something.
public void SendEmail()
{
string emailAdresVan = "invoerenSVP";
string password = "invoerenSVP";
MailMessage msg = new MailMessage();
msg.From = new MailAddress(emailAdresVan);
msg.To.Add(new MailAddress(EmailAdresNaar));
msg.Subject = Onderwerp;
msg.Body = Bericht;
msg.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential loginInfo = new NetworkCredential(emailAdresVan, password);
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = loginInfo;
smtpClient.Send(msg);
}
}
}