I was doing tests to send an email from C #, for it use the following code:
MailMessage message = new MailMessage();
message.To.Add("user@gmail.com");
message.From = new MailAddress("me@server.com");
message.Subject = "Test subject";
message.Body = "Test body";
SmtpClient client = new SmtpClient("server");
client.Timeout = 10000;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
NetworkCredential credentials = new NetworkCredential("me@server.com", "CorrectPassword");
client.Credentials = credentials;
try
{
client.Send(message); // OK
}
catch (Exception ex)
{
MessageBox.Show("Exception caught in CreateTestMessage2(): {0}", ex.ToString());
}
Then, try to start controlling the exceptions for connection interruption and mainly invalid key, but note that even using incorrect keys, the mail was still sent.
NetworkCredential credentials = new NetworkCredential("me@server.com", "BadPassword");
client.Credentials = credentials;
try
{
client.Send(message); // OK, the email has been sent
}
catch (Exception ex)
{
MessageBox.Show("Exception caught in CreateTestMessage2(): {0}", ex.ToString());
}
How do I disable the automatic saving of credentials? Or, how do I erase the stored credentials?