Codestone Ltd logo


download 65236 bytes Tue Aug 26 11:14:20 2003 Zip file


This sample uses a webmail system to demonstrate how to use the Internet Mail Client Control Library on your ISS/ASP site. Using this sample you can:

  • Login to a POP3 server and read the messages in a maildrop.
  • Display the messages and their attachments.
  • Reply to a message.
  • Delete messages on the POP3 server.
  • Compose a new message.
  • Connect to an SMTP server and send a message.

The Webmail sample may provide a useful starting point for your own application but it's not a complete solution - in particular you should consider the following points -

  • Error checking code has been largely omited from the sample so as not to obscure the code.
  • There are security issues around any ISS application. The sample does not address security issues, for example the sample sends inappropriate information through POST requests - this is not something you should do on a non-secured server.
  • The sample caches messages and attachments to improve performance. There is a trade-of between bandwidth and disk space here - caching the message means that if the user reads a message more than once the system doesn't have to download it again from the POP server but it does use disk space on the ISS. You need to consider your local conditions and decide what, if any, caching strategy you need.
  • The sample assumes that all the attachments in a message will have unique names. This is not necessarily the case.
  • The sample also assumes that UIDLs will be unique across POP3 servers, this is a bad assumption, if your application accesses more than one POP3 server you will need to address this.


Files in the webmail sample

Figure 1 shows the relationship between the asp files in this distribution.

User Login Form Inbox Send mail through SMTP server Compose Email Logout Delete mail from POP3 server Read message


Presents the user with a simple HTML form to provide the details needed by the webmail sample.

Note In a production system you'd be more likely to store the user's POP3 and SMTP details locally and have a site specific login.


Connects to the POP3 server, gets the message headers and presents the user with a list of messages in the maildrop. This page uses POP3TOP rather than RetrieveMessages so that only the message headers are retrieved.

Note The sample does not sort the messages in the inbox - they are presented in the same order as the POP3 server returns them, in a production system your users may well expect to be able to sort the messages by Sender, Subject or Date.


Displays the message text and a list of attachments.

Note Only the text/plain sections of the emails are displayed. You will need to decide which textual parts of the email are displayed. Showing text/html sections is tempting but you need to consider if a sender could post malicious HTML and compromise the security of the system. Advanced application may also wish to take into consideration the semantics of the various multipart/* content types.


Deletes a message from the maildrop, redirects the user back to wms_inbox.asp.

This sample does not present the user with an opportunity to confirm or cancel the deletion.


Allows the user to compose an email.

Note It would be cool to allow the user to attach files to the email.


Sends a message to the SMTP server, redirects the user back to wms_inbox.asp.

This sample does not present the user with an opportunity to confirm or cancel the sending of the email.


Clears the IIS session and redirects the user back to wms_login.asp.