And if you don't want to use the default credentials, you have to set the
property UseDefaultCredentials to false BEFORE assigning credentials to the
mailClient object! Dumb, but that's how the code works, as ai found out
while investigating an authentication problem I'm having with SmtpClient. If
you don't set UseDefaultCredentials to false beforehand, the assignment of
credentials is simply ignored.
"CPrice79" wrote:
SmtpClient mailClient = new SmtpClient();
mailClient.Credentials = new NetworkCredential("userName", "password");
"Tim Cowan" wrote:
Hi,
I am using .NET 2.0 and I want to send mail that uses SMTP authorization. I
have found this in the help:
client.Credentials = System.Net.CredentialCache.DefaultCredentials;
My question is how do I set the username and password? Say the username is
bo*@home.com and the password is onions, how do I set this? The values could
be different on a user by user basis, so I need to apply the settings from
the registry.
Thanks
Tim