AspMail/AspQMail Sample Code

Using the ASPMail script is a very straightforward process. All you need do is
specify a page on your web site as the "action" page for your form, and then
include the ASPMail script on that page.

Each form on your website will consist of 2 pages: A "form" page which actually
holds your form, and an "action" page which processes your form when someone clicks
on the "submit" button. For purposes of this discussion, we will refer to these pages
as "form.html" and "aspmailform.asp". *

*Note: Your action page must have a .asp extension, even though it is an ordinary HTML file.

Once you have constructed your form using regular HTML make sure that your <form>
tag specifies the "post" method, and that the action statement points to your "action"
page. Example:

<form action="aspmailform.asp" method="post">

Then, on your action page (aspmailform.asp) you will need to add a block of code similar
to the one below. The Mailer.RemoteHost line will be "mail.yourdomain.xyz" (where .xyz
is your domain extension such as .com). Please note that your domain must be pointing
to our service and you must be using our DNS servers for this to work properly.

 

<%  
      Set Mailer = Server.CreateObject("SMTPsvg.Mailer")  
        
      Mailer.FromName = "WebsiteOrAnything" 
      Mailer.FromAddress"name@yourdomain.com" 
      Mailer.RemoteHost = "mail.yourdomain.com" 
      Mailer.AddRecipient "Name", "name@yourdomain.com"  
      Mailer.Subject = "Form Submission" 
      strMsgHeader = "Form information follows" & vbCrLf  
 
      for each qryItem in Request.Form  
         strMsgInfostrMsgInfo = strMsgInfo & qryItem & " - " & request.Form(qryItem) & vbCrLf  
      next  
 
      strMsgFooter = vbCrLf & "End of form information"  
        
      Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter  
 
      if Mailer.SendMail then  
         Response.Write "Form information submitted..."  
      else  
         Response.Write "Mail send failure. Error was " & Mailer.Response  
      end if  
%> 
 


NOTE:
If you would like to get better mailing performance, you can turn on the AspQMail queuing option
Mailer.QMessage = true

 

You can also get more information on AspMail here: http://www.serverobjects.com/comp/Aspmail3.htm

AspQMail information can be found here: http://www.serverobjects.com/comp/AspQmail.htm

Article ID: 321, Created On: 4/24/2009, Modified: 4/25/2009