Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

ASP Web Based Email Using Dimac w3 JMail

Started by sukishan, Aug 20, 2009, 02:46 PM

Previous topic - Next topic


If you are reading this page then I shall assume that you already know a little bit about ASP and running ASP applications.

The download to this tutorial has 4 working examples of Web Wiz JMail Form's which you can use to allow your web site visitors to send their comments or enquiries to your e-mail address or send emails to their own friends form your site.

However, I not going to go into how the form is written as it uses standard HTML and JavaScript to capture the users details. Instead I'm going to concentrate on the actual methods and properties the w3 JMail object uses to format and then send the email.

The Dimac w3 Jmail component is available for free from and will run on Windows 98, ME, NT, 2000, and XP. You will also need an SMTP server to send the mail messages through, your ISP or web hosts should be able to supply you with one so contact them for the details.

First we need to create the variables that we are going to be using in this script.

'Dimension variables
Dim objJMail     'Holds the JMail Object 

Next we need to create an instance of the 'JMail' object on the server.

'Create the e-mail server object
Set objJMail = Server.CreateObject("JMail.SMTPMail") 

Once the 'JMail' object has been created on the server we can use various properties and methods of the 'JMail' object to build the email.

First we need to specify the address of the SMTP server you are using to send mail through. You can specify more than one SMTP placing a semicolon between the server names. If a server port other than 25 is used you can specify this by adding a colon after the server name.

'Out going SMTP mail server address
objJMail.ServerAddress = "" 

Next we are going to use the 'Sender' property to let the recipient of the email know who the email is from. If you leave the 'Sender' property out or do not have a properly format email address the email will fail.

'Senders email address
objJMail.Sender = "" 

The 'SenderName' property is not necessary and can be left out. This property can be used to specify the name of the sender.

'Senders name
objJMail.SenderName = "My Name" 

Now we need to place a string value representing the email address of the person you want to receive the email into the 'AddRecipient' property of the 'JMail' object. This needs to be a properly formatted email address, also note the lack of the = sign.

'Who the email is sent to
objJMail.AddRecipient "" 

The next property 'AddRecipientCC' holds the email address of the people you wish to receive Carbon Copies of the email.

You can repeat this property property on multiple lines if you wish to send carbon copies to more than one person. Make sure all the email address are properly formatted or the email will fail.

This property can be left out if you don't want any carbon copies of the email sent.

'Who the carbon copies are sent to
objJMail.AddRecipientCC = "" 

The 'AddRecipientBCC' property holds the email address of the people you wish to receive Blind Copies of the e-mail. Like the 'AddRecipientCC' property, this can be repeated on multiple lines for multiple recipients.

Again if you don't want to send any blind copies of the message you can leave this property out.

'Who the blind copies are sent to
objJMail.AddRecipientBCC = "" 

In the next line we use the 'Subject' property to set the subject of the email.

'Set the subject of the e-mail
objJMail.Subject = "Enquiry sent from my web site" 

The JMail component can be used to send mail in either Plain Text or HTML format. I'm going to show you both ways to do it.

First I am going to show you how to send an email in Plain Text format. To do this we use the 'Body' property. If you would rather send the email in HTML format this property can be left and you can use the 'HTMLBody' property instead.

'Set the main body of the e-mail in Plain Text format
objJMail.Body = "Hello." & vbCrLf & "This is my email in Plain Text format" 

The next property were covering is the 'HTMLBody' property, this property is for sending the email in HTML format 'eg. <h2>Hello</h2>
This is my e-mail in HTML format'.

'Set the main body of the e-mail in HTML format
objJMail.HTMLBody = "<h2>Hello</h2>
This is my email in HTML format

The 'Priority' property tells the mail messaging system when to schedule delivery of the email.

For this property there is 3 different integer values, 5 - Low, the e-mail will be sent during times of low system use, 3 - Normal, the message is sent at regular delivery times, 1 - High, the system will attempt to send the message immediately.

If this property is left out the default is Normal.

'Importance of the e-mail (5=Low, 3=Normal, 1=High)
objJMail.Priority = 3 

Once all the properties for the email are set we can now send the e-mail using the 'Execute' property.

'Send the e-mail

Finally once the email has been sent we can close the server object releasing server resources.

'Close the server object
Set objJMail = Nothing

There are other methods and properties of the 'Dimac w3 JMail' component but to keep things simple I have tried to cover the most common properties needed to send an e-mail from your web site.

For more information covering all the methods and properties of this component the full documentation can be downloaded from
A good beginning makes a good ending

Kapil Varshney