|
ASP Web Based Email Using Dimac w3 JMail
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 www.dimac.net 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.
Next we need to create an instance of the 'JMail' object on the server.
 |
 |
 |
 |
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.
 |
 |
 |
 |
objJMail.ServerAddress = "smtp.mySMTPserver.com:25" |
 |
 |
 |
 |
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.
 |
 |
 |
 |
objJMail.Sender = "myE-mailHere@myDomain.com" |
 |
 |
 |
 |
The 'SenderName' property is not necessary and can be left out. This property can be used to specify the name of the sender.
 |
 |
 |
 |
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.
 |
 |
 |
 |
objJMail.AddRecipient "theirEmail@theirDomain.com" |
 |
 |
 |
 |
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.
 |
 |
 |
 |
objJMail.AddRecipientCC = "myFriend@theirDomain.com" |
 |
 |
 |
 |
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.
 |
 |
 |
 |
objJMail.AddRecipientBCC = "myFriend@theirDomain.com" |
 |
 |
 |
 |
In the next line we use the 'Subject' property to set the subject of the email.
 |
 |
 |
 |
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.
 |
 |
 |
 |
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><br><b>This
is my e-mail in HTML format</b>'.
 |
 |
 |
 |
objJMail.HTMLBody = "<h2>Hello</h2><br><b>This is my email in HTML format</b>" |
 |
 |
 |
 |
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.
Once all the properties for the email are set we can now send the e-mail using the 'Execute' property.
Finally once the email has been sent we can close the server object releasing server resources.
 |
 |
 |
 |
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 www.dimac.net.
|
|
|