SYSK 146: SMTP – More Configuration, Less Code

If you’re using SmtpMail class in your projects, you may want to check out a new class in .NET 2.0 -- System.Net.SmtpClient.


This class allows you to send messages asynchronously and to receive a notification when the e-mail has been sent.  You can also cancel any pending asynchronous e-mails.  And there is less code to write! -- Settings such as a host to use, the default ‘from’ e-mail account, etc. can be defined in your application, web site or machine configuration file instead of setting object properties in code:





      <smtp deliveryMethod="network" from="">













SmtpClient client = new SmtpClient();

constructor will initializes the Host, Credentials, and Port properties for the new SmtpClient by using the settings in the application or machine configuration files, if they are available…


Source:  ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/dv_fxgenref/html/220b0329-e384-4e0c-86b4-0945ad17efd9.htm


Comments (2)

  1. Really quite tired tonight – this morning – but I thought I’d post some stuff I’d found that might be…

  2. RR says:

    Thanks for the tip! Great to know that the underlying code will inspect the config file for you.

Skip to main content