473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

.NET 2.0 System.Net.CredentialCache

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
Jan 30 '06 #1
2 2617
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

Jan 30 '06 #2
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

Feb 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
0
by: Steve Ng | last post by:
Hello, I have a windows form application that needs to pass through a proxy to get access to the internet. As a test, I have successfully hardcoded my login/password/domain combination and been...
1
by: goddyg | last post by:
I have a windows form application that needs to pass through a proxy to get access to the internet. As a test, I have successfully hardcoded my login/password/domain combination and been able to...
3
sid0404
by: sid0404 | last post by:
Hi I am new to the programming in c#, I have an application where I need to get data from a website now I am getting an error message if I give the input as two strings, say Sun Microsystems while...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.