Handling E-mail with HTML, CDO, and SMTP

Handling E-mail with HTML, CDO, and SMTP

here are some mighty powerful e-mail solutions out there in network land. Just look atthe size of Microsoft Exchange. But how about handling your intranet e-mail with somethingfast, light, cheap and flexible? In this two-part series, we?re going to show how toplay postmaster using Active Server Pages (ASP), Collaboration Data Objects for NT Server(CDONTS) and the Simple Mail Transfer Protocol (SMTP) service. Remember: it all comes freewith Windows NT 4.0.

In this first article we?ll walk through the configuration and verification of theSimple Mail Transfer Protocol service on Internet Information Server. We?ll show howto post an e-mail message from an HTML form and show you what the message looks like inthe raw. In the second article we?ll show how to pull messages out of a mail folderand put them into an Access database or onto a Web page. Although this information isoriented towards an intranet application, the concepts apply Web-wide.

Configuring the Mail Service
Before going further, make sure that SMTP is installed with Internet Information Server4.0. If SMTP wasn?t included in your original installation, run the Windows NT 4.0Option Pack setup to add it.

Let?s say we?re working for Passable Computers (“Our ComputersAren?t Just Great, They?re Passable”). Your customer service requests on atWeb form to go to the service department?s mailbox. Let?s go to InternetInformation Server 4.0 and create an SMTP domain for Passable.

  1. Start the Internet Service Manager, by clicking Programs>Windows NT 4.0 Option Pack>Microsoft Internet Information Server>Internet Service Manager.
  2. In the Microsoft Management Console (MMC), expand the Internet Information Server node and expand the server name (P75). See Figure 1.
  3. Right click on Default SMTP Site.
  4. Click New and then click Domain.
  5. In the New Domain Wizard, make sure the domain type Local is selected and then click Next. See Figure 2.
  6. Type the name for the new mail domain, for instance passable.com. See Figure 3.
  7. Click Finish to return to the display

Having created the mail domain for passable.com, we need to configure the mail site toaccept messages. Our task includes creating a directory where the mail will be dropped.

  1. In the MMC?s left-hand pane (also called the scope pane), click the Domains icon. The list of domains appears in the right-hand pane, as in Figure 4.
  2. In the right-hand pane, select the domain that you just created (passable.com), right-click and from the context menu, click Properties.
  3. We?re going to make passable.com the default local domain, so click Local and Default. Confirm the change if a dialog box appears.
  4. All messages go into the drop directory. In our case we?ll create a new directory to hold the messages by typing c:InetpubMailrootpassable.com. See Figure 5.
  5. Click OK to exit the properties page.
  6. Exit the MMC.

Configuring the Domain Name
Normally, passable.com would have its own domain name server (DNS) entry. But duringdevelopment, let?s just configure one workstation to send mail to the mail drop box.Adding the server?s name and IP address to the Hosts file on your client Windowscomputer makes sure the client can find the SMTP site.

  1. Find the Hosts file (usually in c:windows) and open the file in Notepad.
  2. Add an entry for the SMTP server?s IP address (e.g.,, a space, and the mail server?s alias (e.g., passable.com). See Figure 6.
  3. Save the Hosts file and exit Notepad.

Setting Up an HTML Form to Send E-mail
Now that you?ve mapped the IP address to the host (mail server) name we can diginto some ASP code. We need an HTML form to post on the Web server with the rest ofPassable?s site. We fire up Visual InterDev and put together a barebones HTML formthat will submit e-mail messages to [email protected]. The following single page ofcode (response.asp)  does it all. It provides the form to submit the message, sendsthe e-mail and provides user feedback.

Notice the use of the CDONTS object in the VBScript code. CDO is another free componentof IIS. The NewMail object is especially attractive for quick mailers like this one. Thecode here sets various message properties such as the recipient’s name and message body.To make sure we don’t lose the sender’s friendly name, I’ve tacked it on to the Subjectproperty. In the browser, the form looks like Figure 7.

Passable Computers Service

Our service is Passable too!

<% if request("formemail") = "" then%>





We'll be in touch with you soon.

<%Set myMail = CreateObject("CDONTS.NewMail")
myMail.From = request("formemail")
myMail.To = "[email protected]"
myMail.Subject = "Service inquiry - " & request("formname")
myMail.Body = request("formmessage")
Set myMail = Nothing
end if

Peering into the SMTP Mailbox
Let?s confirm that our e-mail message to [email protected] arrived at the SMTPserver. We need to peer into a file directory on the Web server.

  1. On the Web server, open Windows Explorer and navigate to C:InetpubMailrootpassable.com. See Figure 8.
  2. In Notepad, open the file that has the extension .EML.

When you look at the following text, you see that there?s more than meets the eye.In your mail reader, this is a one-liner. Clearly, there?s a lot of overhead in ane-mail message.

x-sender: [email protected]
x-receiver: [email protected]
Received: from mail pickup service by p75.winnt with Microsoft SMTPSVC;
Tue, 7 Jul 1998 22:45:09 -0400

To: [email protected]
Subject: Service inquiry - Ken Cox
Date: Tue, 7 Jul 1998 22:45:08 -0400
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Message-ID: [email protected]
Please send a service contract.

In this first article, we?ve set up the basic SMTP e-mail system for our intranet.We?ve configured the server, created a directory to receive the e-mail, set up theHTML form to send messages to our mail site and we?ve seen what the mail messagelooks like in its raw form.

In the next article, we?ll use Active Server Pages code to retrieve the mail fromthe mailbox and put the contents, subject and sender information into an Access databaseas well as on a Web page. The techniques for manipulating e-mail open up many possibilities for managing messages and automating replies.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes