Use System. Web. Mail to send emails in the. NET application
Author: Mark Strawmyer
Dates: February 9, 2004
--------------------------------------------------------------------------------
Welcome to the. NET Nuts & Bolts section. In this section, we will explore how to send emails in applications. This will use the class in the System. Web. Mail namespace.
Collaborative Data Objects
Windows 2000 collaborative data object (CDOSYS) is a messaging component that Microsoft uses to create and send standard-based email messages. It is a substitute for collaborative Data Objects (CDONTS) with Windows NT.
Although CDONTS is included in Windows 2000 due to backward compatibility, Windows XP, Windows Server 2003, and later versions do not contain or support CDONTS components.
Therefore, any application that uses CDONTS to send messages must be migrated to CDOSYS. It provides the same functions and is easy to use.
In addition to being a substitute, CDOSYS also introduces functions not available in CDONTS, such:
Ability to send messages to newsgroups
Control the message MIME Body Structure
Receiving and forwarding mechanism
Transport event acceptance pool to respond to events
The System. Web. Mail namespace contains classes that interact with the CDOSYS component to create and send information.
Use Internet Information Service (IIS) and SMTP Service
To use CDOSYS to send emails from applications, make sure that the SMTP service is installed in the IIS service list. In Windows 2000/XP, you can choose Control Panel> Add/delete Programs> Add/delete Windows Components. The task of the STMP service is to receive and send messages based on configurations. This service can deliver messages directly or use a proxy server to send messages. When the current server is configured, all messages will be forwarded to it for sending. Make sure that IIS and SMTP services are correctly installed and configured.
Before delivery, the SMTP service uses a directory structure to save messages. The default directory is C: Inetpubmailroot. This folder contains subdirectories, such as Queue, Drop, and Badmail.