I'm trying to build a little WPF email sender tutorial but I don't want to share it if it has this glaring bug.
Currently, this is what happens.
- user types in username and password.
- label 'loginstatus' changes to "Logged in" regardless if it's gibeerish or not.
- Message body and send to fields are enabled.
- user pressed "Send" button and if there is an exception (for example, wrong username/password) the messagebox shows it, and loginstatus is changed back to logged out.
This is very very wrong and I want to fix it.
How can I just 'ping' to see if a credential is correct (without sending a test email).
I'm using smtp.gmail.com port 587
Edit Here's how I'm sending the emails.
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential(username, password),
EnableSsl = true
};
try
{
client.Send(fromEmail, toEmail, subject, body);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}