saqib.razzaq:
jay_bp:Also, with both, I have to specify the username/password in the constructor, rather than setting the properties after the Connect call.
The sample which I attached is based on your example. It
- Calls Connect(false)
- Sets user and password
- Calls Login()
All 3 steps worked fine at my end with correct user/pwd, without any exception.
If we remove the username/password from the constructor, then the first client call after the .Login() call throws an exception:
using (var client = new Pop3Client(host, port)) // No username/password here
{
client.SecurityMode = Pop3SslSecurityMode.Implicit;
client.EnableSsl = true;
try
{
client.Connect(false);
}
catch (Exception ex)
{
Console.WriteLine("Connection Error: " + ex);
return;
}
try
{
client.Username = username;
client.Password = password;
client.Login();
}
catch (Exception ex)
{
Console.WriteLine("Login Error: " + ex);
return;
}
// The server must implement this command
Console.WriteLine("Connection Success: {0} messages", client.GetMessageCount()); //This throws an exception