Article ID: 555287 - View products that this article applies to.
This article describes how to send e-mails from a .NET application through an SMTP server that requires authentication.
Exchange Server requires, by default, authenticated users to send mail messages via SMTP. If you are developing a .NET application you will find that System.Web.Mail does not contain an API that allows you to provide credentials for connecting to an SMTP server. System.Web.Mail internally calls Microsoft® Collaboration Data Objects CDOSYS. SMTP Authentication is possible by defining configuration settings using the Configuration object associated to the Message CDO object.
The System.Web.Mail namespace provides an API that enables you to create and send messages using the CDOSYS (Collaboration Data Objects for Windows 2000) message component. The mail message is delivered through an SMTP server.
Most of the SMTP servers installations requires authentication. The main reasoning for this is due to people abusing SMTP servers for SPAMing (i.e., sending out unsolicited junk mail).
The System.Web.Mail namespace classes don't expose an API for providing credentials to an SMPT server. Anyway you can achieve this by defining configuration settings for the Configuration object associated to the Message CDO. Configuration settings are made up of a set of fields (properties) that are simply name/value pairs. Most configuration fields used for messaging are in the http://schemas.microsoft.com/cdo/configuration/ namespace.
You can set fields to the message by adding them to the System.Web.Mail.MailMesage.Fields collection.
CDO Fields for configuring SMTP Authentication
To configure Message objects, you modify fields in the associated Configuration object. Most of the field names reside in the http://schemas.microsoft.com/cdo/configuration/ namespace:
The following example shows how to send an e-mail through an SMTP server that requires authentication server over the network by providing credentials in clear-text.
Note: The classes in the System.Web.Mail namespace can be used from ASP.NET or from any managed application. Be sure that your project references the System.Web.dll assembly.
For more information about Collaboration Data Objects visit:
For more information about the System.Web.Mail namespace visit:
Article ID: 555287 - Last Review: April 7, 2005 - Revision: 1.0
COMMUNITY SOLUTIONS CONTENT DISCLAIMER
MICROSOFT CORPORATION AND/OR ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY, RELIABILITY, OR ACCURACY OF THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN. ALL SUCH INFORMATION AND RELATED GRAPHICS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT AND/OR ITS RESPECTIVE SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS INFORMATION AND RELATED GRAPHICS, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, WORKMANLIKE EFFORT, TITLE AND NON-INFRINGEMENT. YOU SPECIFICALLY AGREE THAT IN NO EVENT SHALL MICROSOFT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OF OR INABILITY TO USE THE INFORMATION AND RELATED GRAPHICS CONTAINED HEREIN, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF MICROSOFT OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES.