How do I send email from a web page using ASPMail?

Using the ASPMail component to send a message from a web page is as simple as:

 - Creating the object
 - Setting a few properties
 - Calling the SendMail method

The following code demonstrates how to use AspMail from VBScript on a .asp web page. In this example, Joe from Joe’s Widgets wishes to send an email to John Smith. Joe’s outgoing SMTP server is located at

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName   = "Joe’s Widgets Corp."
Mailer.FromAddress= ""
Mailer.RemoteHost = ""
Mailer.AddRecipient "John Smith", ""
Mailer.Subject    = "Great SMTP Product!"
Mailer.BodyText   = "Dear Stephen" & VbCrLf & "Your widgets order _
 has been processed!"
if Mailer.SendMail then
  Response.Write "Mail sent..."
  Response.Write "Mail send failure. Error was " & Mailer.Response
end if

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

Note: Change the RemoteHost parameter to use the name of your own domain.

RemoteHost = ""

When your website was first setup, two files were placed in your /scripts folder:


Please reference these files for a complete working example.

For full documentation and more examples of using ASPMail, please visit 

Add Feedback