About ASPMail 2.0

ASPMail allows you to send mail using the standard SMTP protocol from any program that can use ActiveX/OLE components. Features include:

  1. SMTP (sending) Messages
  2. Multiple File Attachments
  3. File attachments support MIME and UUEncoding
  4. US Ascii and ISO-8859-1 character sets
  5. PGP
  6. Redundant SMTP servers (If the primary SMTP server is down, the secondary server is used)
  7. Special Header Support (Standard X-Priority headers, MS Mail (including Exchange) priority headers, Urgent header, ConfirmReading and ReturnReceipt Headers)
  8. Multiple concurrent users (Tested with 15 concurrent connections)

Changes in ASPMail 2.0

ASPMail 2.0 builds on the functionality of ASPMail 1.0 by replacing the SMTP "plumbing" with an improved implementation, replaces a number of properties with methods to clarify email addressing, provides a complete type library and provides dual interface support. In addition to the changes:

1.) The RemoteHostB property was removed and combined with the RemoteHost property. ASPMail can now try up to three SMTP servers in attempting to send an email. Seperate the different SMTP server addresses with a semicolon.

2) The Recipient, CC, and BCC properties have been replaced with AddRecipient, AddCC and AddBCC methods. This new scheme provides for better addressing. There are also 4 new methods: ClearRecipients [To:], ClearCCs [CC:], ClearBCCs [BCC:] and ClearAllRecipients which allow you to empty the recipient lists once addresses have been added. Please note that under AspMail 1.x recipient was a property but the AddRecipient family are methods. See the following docs for the proper calling convention.

3) The DNSLookup method was removed.

ASPMail Installation

To use this ASP component move the DLL into a subdirectory (like \winnt\system32 for NT or \windows\system for Win95). Please use the version of regsvr32 that is included with this component or the version that comes with Microsoft ASP (they are the same version).

To register the component on the system change to the directory where you installed the DLL and type:

regsvr32 smtpsvg.dll

You may need to modify this example based on the directory you have installed the component to.

You should finish installation by running the MarkSMTP utility included with this package. This utility will mark the component as apartment model in the system registry.

Simple Mail Example

Using the component is as simple as

  1. Creating the object
  2. Setting a few properties
  3. Calling the SendMail method

The following code demonstrates how to use ASPMail from VBScript. In this example Joe from Joe’s Widgets wishes to send an email to John Smith at Tools Corp. Joe’s mail server is located at mailhost.localisp.net.

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName   = "Joe’s Widgets Corp."
Mailer.FromAddress= "Joe@Widgets.com"
Mailer.RemoteHost = "mail.localweb.com"
Mailer.AddRecipient "Steve Genusa", "steve@genusa.com"
Mailer.Subject    = "Great SMTP Product!"
Mailer.BodyText   = "Dear Stephen" & Chr(13) & Chr(10) & _
                     "Your widgets order has been processed!"
if Mailer.SendMail then
  Response.Write "Mail sent..."
  Response.Write "Mail send failure. "
end if

By testing the result of the SendMail method we can determine if the mailing process was successful or not.

Form Handling

All or partial input for a message may come from a form. For example, a form posted to the server with a request method of GET (i.e. <form action="/scripts/aspmail.asp" method=get>) may provide the message recipient’s email address, subject and message text as follows:

Mailer.AddRecipient Request.QueryString("ToName"), Request.QueryString("ToAddress")
Mailer.Subject   =  Request.QueryString("Subject")
Mailer.BodyText  = Request.QueryString("MsgBody")

The form may also use the POST method (i.e. <form action="/scripts/aspmail.asp" method=post>) in which case the code would look as follows:

Mailer.AddRecipient Request.Form("ToName"), Request.Form("ToAddress")
Mailer.Subject   =  Request.Form ("Subject")
Mailer.BodyText  = Request.Form ("MsgBody")

You can use any mixture of static and dynamic data in setting the components properties as dictated by your needs. For example, you may wish to send the mail to a single user. In this case you could modify the code to look something like this:

Mailer.AddRecipient "Stephen Genusa", "steve@genusa.com"
Mailer.Subject   =  Request.QueryString("Subject")
Mailer.BodyText  = Request.QueryString("MsgBody")

Generic Form Handling

In some cases users may wish to use a number of different forms to send email with the same block of code. ASP allows you to loop through each QueryString or Form variable and append each one to string variable which is then assigned to the BodyText property.

strMsgHeader = "Form information follows" & vbCrLf
for each qryItem in Request.QueryString
   strMsgInfo = strMsgInfo &  qryItem & " - " & request.querystring(qryItem) & vbCrLf
strMsgFooter = vbCrLf & "End of form information"
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter

Setting Mail Priority

There are a couple of headers that can be modified to set message priority.

The Priority property sets the message priority on a scale of 1 to 5. A priority of 1 means HIGH. A priority of 3 means NORMAL and a priority of 5 means LOW. In addition to this you can also set the Urgent property if the message status is urgent. The Urgent property is a true/false property.

Notes About Creating the Mailer Object

You can create the mailer object at two different points in time:

Immediately before sending an email
At the session scope and saved as a session object

You will have to decide when and where it is appropriate to create the object based on your particular application. If you aren't sure which way to create the object reference, or for typical usage, you should create the object immediately before sending your email. Your code would look like this:

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
... [Set properties]
if Mailer.SendMail then ...

Creating these local references, as demonstrated above, allow you to use the object on multiple application threads at the same time.

If you wish to create and reuse the object at the session scope you must insure that only one user is using the session object reference using some queing mechanism.

To create an object reference at the session level, your code might look something like this:

if Not IsObject (session("Mailer")) then
  Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
  Set session("Mailer") = Mailer
  Response.write "Cached session object reference being used<p>"
  Set Mailer = session("Mailer")
end if

Multiple Host Support

ASPMail provides one host property to set up remote SMTP server addresses. The RemoteHost property should be set to your primary and secondary server’s address seperated by semicolons. In the event that the primary server is down, ASPMail will attempt to use the secondary server. For example,

Mailer.RemoteHost = "mail.localweb.com;mailhost.anotherisp.com"

PGP Support

AspMail now supports PGP. See the pgpmail.asp script for an example of usage.

About purchasing ASPMail

  1. The registration license fee covers only one CPU per license. The fee per CPU is $49.95. We have priced the component at a level where we hope that companies or individuals using multiple copies will respect the license agreement.
  2. Attachments are enabled in the registered version but not in eval copies.
  3. An X-Header has been added (that is normally not displayed by most email programs) showing who the component is registered to. When you register make sure that the name you want displayed is included in your registration information. Normally this will be a company name. Changes will NOT be made once the product has been shipped to users who register.

About Upgrades

  1. Who can upgrade?
  2. Users can upgrade for free for minor version changes. For example, upgrades from version 1.00 to 1.99 are free. The upgrade from 1.99 to 2.0 may carry an additional license fee.
  3. How to get upgrades
  4. The latest version of the components are always available at http://www.genusa.com/asp/aspcomp.html. If a fee is associated with obtaining the upgrade it will be noted on that page.
  5. How to install
Stop all IIS related services such as Gopher, FTP and W3SVC. Uninstalling the old DLL is not necessary. If the DLL has been loaded you will get an error message saying the file is in use by another process. Stop that process and then copy the file. Restart the necessary services.

Upgrade Instructions

To upgrade the component from a previous version please follow these steps:

  1. Change to the directory where the component is located and type "regsvr32 /u smtpsvg.dll"
  2. Move the new copy of smtpsvg.dll to the current directory and type "regsvr32 smtpsvg.dll"
  3. If you were using AspMail 1.x, be sure and modify any code that uses the Recipient, CC and BCC properties to use the new methods.

Common Problems

Server object error 80040154.
This is the most common error reported. The error means that ASP could not create the object. Causes include:

  1. You never ran regsvr32 on the DLL. See installation section of this document.
  2. You registered the DLL with regsvr32 in one subdirectory and moved it to another.
  3. IIS does not have proper security permissions to access the DLL or the directory you installed it to. See the ASP FAQ (http://www.signmeup.com/faq/) for information on changing security.
  4. Your server may be running low on memory.

Note: Some users have reported that restarting the server after registering the DLL was required to use the component. This should not be necessary but reportedly works in a few cases.

How do I get Exchange to route Internet email to the Net?
Well, basically you have to configure Exchange (5.0) to support POP3. It is not installed that way by default (not with the release candidate at least!). The problem is that when you email from outside the Exchange client, the server goes looking at the global address list and if the address you're emailing to is not there, you'll get an error. With POP3 support enabled, you can configure Exchange to route unknown addresses to other servers and that solves the problem. (Thanks to Fernando Santos for this info!)

The message text keeps growing with each email I send.
Use the ClearBodyText method if you are reassigning the message text for multiple emails.

Technical Support

If you require technical support please send complete details about the problem you are having. Include the version of AspMail you are using, sample code snippets that demonstrate the problem (most problems are scripting errors), information about the hosting environment etc. For example, if you are using ASP to host the component please let me know what version of IIS and ASP you are running (and have you installed any of the HotFixes). The more information you can provide in your request for help, the faster your problems can be resolved.

ASPMail Properties

BodyText The message body text. To optionally clear the text once you have set it use the ClearBodyText Method.


Mailer.BodyText = "Your order for 15 widgets has been processed"

CharSet The character set. By default the char set is US Ascii

Valid values:

1 = US Ascii

2 = ISO-8859-1


Mailer.CharSet = 2

ConfirmRead The ConfirmReading flag. If this is set to true AND the recipients email program supports

this feature (and it is enabled) the recipients email program will send a notice back to the FromAddress confirming that this email has been read.


Mailer.ConfirmRead = true

ContentType The ContentType property allows you to set the ContentType header of the message's BodyText. If, for example, you wanted to send HTML as the messages's body, you could set ContentType = "text/html" and EMail programs that support HTML content could properly display the HTML text.

Note: The ContentType property is ignored if you have file attachments.


Mailer.ContentType = "text/html"

DateTime AspMail will, by default, create a Date/Time header for your local system using GMT. If you would like to override the date/time calculation set the DateTime property to a valid date/time string in the format defined by RFC 822 & RFC 1123.


Mailer.DateTime = "Fri, 02 May 1997 10:53:49 -0500"

Encoding The encoding type for attachments. The default setting is MIME.

Valid values:

1 = UUEncoded

2 = MIME


Mailer.Encoding = 1

Expires If the component is an eval version the expires property will return the date that the component quits functioning.


Response.Write "Component Expires: " & Mailer.Expires

FromName The message originator’s name.


Mailer.FromName = "Joe’s Widget Shop"

FromAddress The message originator’s email address.


Mailer.FromAddress = "joe@widgets.com"

PGPPath The path where PGP is located.
PGPParams Parameters that PGP will use to process message.
Priority Sets the message priority. Priorities are 1-5 and are reflected in the X-Priority

Valid values:

1 – High

3 – Normal

5 – Low


Mailer.Priority = 1

RemoteHost The remote SMTP host that the message will be sent through. This is typically an SMTP server located at your local ISP or it could be an internal SMTP server on your companies premises. Up to 3 server addresses can be specified, seperated by a semicolon. If the primary server is down the component will attempt to send the mail using the seconary server and so on.


Mailer.RemoteHost = "mail.localweb.com" or

Mailer.RemoteHost = "mail.localweb.com; mailhost.myotherisp.net"

ReplyTo The ReplyTo property allows you to specify a different email address that replies should be sent to. By default mail programs should use the Reply-To: header for responses if this header is specified.
Response The Response property returns any error messages that may occur.
ReturnReceipt The ReturnReceipt flag. If this is set to true AND the recipients SMTP server supports

this feature (and it is enabled) the recipients SMTP server will send a notice back to the FromAddress confirming that this email has been delivered.


Mailer.ReturnReceipt = false

SMTPLog If you need to debug the session give a log file name here. Make sure the IUSR_XYZ IIS user has security that allows the component to write to this file. Warning: Do not use this setting in situations where multiple users can access this component at the same time. This is for single user debugging ONLY!


Mailer.SMTPLog = "c:\smtplog.txt"

Subject The message subject.


Mailer.Subject = "Stock split announced!"

TimeOut Timeout is the maximum time that ASPMail should wait for a response from the remote server. The default is 30 seconds.


Mailer.Timeout = 15

Urgent The urgent flag sets the X-Urgent header in the outgoing message. Not all mail readers support this flag.


Mailer.Urgent = true

UseMSMailHeaders MS-Mail priority headers, by default, are sent in addition to the standard SMTP priority headers. You can turn MS-Mail headers off with this property


Mailer.UseMSMailHeaders = false

Version Gets the internal component version number.


Response.Write "Component Version: " & Mailer.Version

WordWrap The WordWrap property is off by default. Setting WordWrap to true causes the message body to wordwrap at the position specified by the WordWrapLen property.
WordWrapLen The WordWrapLen property is set to 70 by default. You can modify the position that wordwrap occurs by changing this value.

ASPMail Component Methods

Method Parameters Return Value Description
SendMail None True or False


if Mailer.SendMail then

Response.Write "Mail sent..."


Response.Write "Mail failure. Check mail host server name and tcp/ip connection..."

end if

The SendMail method attempts to send the email.
AddRecipient Mailer.AddRecipient "Steve Genusa", "steve@genusa.com" True/False based upon success or failure. Adds a new recipient, as shown in the message's To: list.
ClearRecipients None None Clears any recipients assigned to the To list.
AddCC Mailer.AddCC "Steve Genusa", "steve@genusa.com" True/False based upon success or failure. Adds a new recipient, as shown in the message's CC list.
ClearCCs None None Clears any recipients assigned to the CC list.
AddBCC Mailer.AddBCC "Steve Genusa", "steve@genusa.com" True/False based upon success or failure. Adds a new Blind Carbon Copy recipient. BCC recipients are not shown in any message recipient list.
ClearBCCs None None Clears any recipients assigned to the BCC list.
ClearAllRecipients None None Clears all recipients assigned to the To, CC and BCC lists.
AddAttachment Filename to attach to message.


Mailer.AddAttachment "p:\shipping\proddsk1.zip"

True or False Adds attachments to current mailing.

Make sure that the IUSR_XYZ IIS user, or the authenticated user has security rights that allow the component to read the necessary files! Note: Attachments are not supported in the eval version

ClearAttachments None None Clears any attachments that were previously set.



ClearBodyText None None Clears any text assigned to the message’s body which may have been set previously by using the BodyText property.
ClearExtraHeaders None None Clears any X-Headers that were set by use of AddExtraHeader.
AddExtraHeader A string value that forms a proper SMTP X-Header


("X-HeaderName: XHdrValue")

True or false. Returns true if X-Header was added. Adds extra X-Headers to the mail envelope.
GetBodyTextFromFile See pgpmail.asp for more information. See pgpmail.asp for more information. Loads message's body text from a file. Optionally runs PGP on the message text.

See pgpmail.asp for more information.


Copyright 1996, 1997 by Stephen Genusa. All Rights Reserved.