473,687 Members | 3,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET 2.0 System.Net.Cred entialCache

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.Credenti als = System.Net.Cred entialCache.Def aultCredentials ;

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 2643
SmtpClient mailClient = new SmtpClient();
mailClient.Cred entials = new NetworkCredenti al("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.Credenti als = System.Net.Cred entialCache.Def aultCredentials ;

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 UseDefaultCrede ntials 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 UseDefaultCrede ntials to false beforehand, the assignment of
credentials is simply ignored.

"CPrice79" wrote:
SmtpClient mailClient = new SmtpClient();
mailClient.Cred entials = new NetworkCredenti al("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.Credenti als = System.Net.Cred entialCache.Def aultCredentials ;

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
9134
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 system.windows.forms.dll
3
397
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 system.windows.forms.dll
0
8309
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 able to gain access through the proxy. I would like to ditch the hardcoded login/password/domain combination and use the settings defined in Internet Explorer. I've read that I can use System.Net.CredentialCache.DefaultCredentials to get the
1
4339
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 gain access through the proxy. I would like to ditch the hardcoded login/password/domain combination and use the settings defined in Internet Explorer. I've read that I can use System.Net.CredentialCache.DefaultCredentials to get the credentials...
3
1910
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 f I just give one input then I have the following error message: An unhandled exception of type 'System.Net.WebException' occurred in System.dll Additional information: The server committed a protocol violation. Section=ResponseStatusLine ...
0
8590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8783
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7617
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6450
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4541
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2960
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2214
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.