09-04-2012, 11:10 AM
SMTP mail Introduction
SMTP mail Introduction.doc (Size: 1.09 MB / Downloads: 71)
Introduction
The article addresses two topics: sending an email message to a standard email account, and sending an SMS message to a cell phone or pager. The approach uses the SMTP client contained in System.Net to accomplish both types of message submittal, and all messages are sent from ASP.NET 2.0 ASPX pages.
The SMTP email portion application will demonstrate the following:
Using SMTP to configure and send email messages
Adding �CC� addresses as message recipients
Adding attachments to a message
The SMS portion of the email application will demonstrate the following:
Passing standard email messages through the carrier to deliver SMS messages to the target.
In addition to discussing the small bit of code necessary to send these messages, the document will address the primary configuration requirements needed to successfully send messages through an ASP.NET 2.0 based website on an IIS server.
In order to use this demonstration, you should have an instance of IIS installed on your development machine, you should have Visual Studio 2005 installed, and you should have the optional SMTP mail server installed in your local IIS instance.
Figure 1: The main page of the demonstration application
Getting Started
Unzip the attached file; in it, you will find a solution containing a web site project entitled, �RealMail�. Store the unzipped file onto your system, and create a virtual directory pointing to the web application from IIS. Then, open the solution in Visual Studio 2005. Looking at the Solution Explorer, you will see the files indicated in figure 2.
Figure 2: RealMail web application in the Solution Explorer
There are two ASPX pages in the solution, the first (default.aspx) is used to send a standard message to a recipient using the .NET 2.0 SMTP class library; the second page is used to send an SMS message to a cellular telephone or messaging pager through SMTP.
IIS Configuration
Your local IIS instance has to be properly configured in order to successfully send an email message through its SMTP mail server. Even if you install IIS, the SMTP mail server installation is optional, and must be explicitly added to the installation. If you are not sure whether or not the SMTP mail server is installed, open up the IIS control panel and check for the installation; if it is installed, you will see a reference to the Default SMTP Virtual Server in the tree view (Figure 3):
Figure 3: Default SMTP Virtual Server installed
If the server is not installed, you will need to use the �Add and Remove Windows Components� function in the �Add and Remove Programs� control panel to add the SMTP server to your IIS installation. If you need to do this additional installation, once you�ve opened �Add and Remove Windows Components�, click on �Internet Information Services (IIS)� to highlight it, and then click on the �Details� button (Figure 4). This will open an IIS dialog; examine this dialog to locate �SMTP Service�, and click on it to place a check mark on the box (Figure 5). Once this item has been checked, click on the �OK� button to install the SMTP server.