The Collaboration Data Objects for Windows NT Server (CDONTS) component is installed when you install IIS on NT4 and Windows 2000. It’s a valuable tool for sending generic e-mails without having to worry about all the intricacies of SMTP/ESMTP. However, sometimes, you may want a little more control over the e-mail and its headers.

I recently encountered such a situation when there was a need to track replies to e-mails that originated at our location. If we delivered e-mail to users automatically, and a user replied to a particular e-mail, how would we track which e-mail the user was sending a response to?

We could put an identifier in the subject or body of the e-mail, but the user can clear both of those areas. Another alternative is RFC 822, which defines a list of header information for Internet messages, including MESSAGE-ID and IN-REPLY-TO. If we could provide useful information in the MESSAGE-ID of the original e-mail, a reply should contain that information in the IN-REPLY-TO header. However, CDONTS doesn’t let you modify this header information. That means we need to modify it ourselves.

A simple way to modify this header information is through direct SMTP. An example of a generic SMTP session goes something like this:
220 REMOTE.SERVER Simple Mail Transfer Service Ready
MAIL FROM:johndoe@remote.server
250 OK
RCPT TO:janedoe@remote.server
250 OK
354 Start mail input; end with <CRLF>.<CRLF>
To: janedoe@remote.server
From: johndoe@remote.server
Message-ID: oicu812

This is the body of the message.

250 OK
221 REMOTE.SERVER Service closing transmission channel


To have this conversation with the remote server, you simply connect to the server through port 25 (most of the time) and chat away.

Now, we create a Visual Basic ActiveX DLL project and add a form to it. We’ll keep the default name of Form1 for this example. Then, we add the Microsoft Winsock Control to our toolbar and add this component to the form. We’ll set the form’s Visible property to False and add this code to the form, as shown in Listing A.

This code is bare, without much capability for error handling, and some of the techniques could be achieved in a more desirable fashion. However, it does show the basic technique for sending e-mails using SMTP. If all goes well, you should be able to use it to send simple e-mails.

Some ESMTP servers require authentication, which is beyond the scope of this article. For information about SMTP extensions, read RFC 2554.

After you’ve changed this header in the outbound e-mail, you’ll need to check the In-Reply-To header in the reply e-mail. In my situation, I was able to accomplish this through Lotus Notes. You can also do it through CDONTS. Once you have the In-Reply-To message header, you can reference the originating e-mail with the reply e-mail. This provides a quick and easy method for tracking e-mails using existing Internet standards.