w3 JMail
Note: only the Professional edition of w3 JMail includes massmailing and mail-merge.
Massmailing personalized e-mails with Dimac w3 JMail
A very common way to keep in touch with your web site visitors is to send e-mails
to them whenever you update your website. With w3 JMail mailmerge
functions you can personalize each e-mail with the recipient’s name and other
details that you have collected. Mailmerge works in the way that you first cre-ate
a template from which you create the e-mails. The template can contain
any number of merge fields which are replaced with personal information.
For example, if the following were your template:
Hi %%name%%!
You have %%ordersCount%% orders in process.
You could easily see the merge fields as they begin and end with a double
percentage mark (%).
Now let us take a look at the example. First we will create a message object
that will serve as a template for the merge:
set msgTemplate = Server.CreateObject( “JMail.Message” )
msgTemplate.Subject = “Hi %%Name%%!”
msgTemplate.Body = “Hello %%Name%%, .... bla bla...”
msgTemplate.From = “me@myDomain.com”
msgTemplate.FromName = “Mailinglist info!”
msgTemplate.AddRecipient %%EMail%%, %%Name%%
Note how we actually use merge fields in the recipient fields as well. There, our
message template is done. Next we create the mailmerge object:
set mMerge = Server.CreateObject( “JMail.MailMerge” )
mMerge.MailTemplate = msgTemplate
That was the first part, now we need a group of recipients. In this example we
use an ADO recordset, however, it is possible to do it manually if you have a list
of recipients on a file or so. It is assumed that we already have established a
connection to our SQL server and that the connection is called sqlCon.
As you see we enter our mail server address because the BulkMerge method
sends the e-mails as soon as it has merged them, thus you don’t need to use
the send() method.
The BulkMerge method can also be used in conjunction with w3 JMail’s enque
method. Just set the second parameter to TRUE, skip the last parameter and
the e-mails will be enqued, which is most often the preferred way to do it as
massmailing can be a bulky operation (hence the name BulkMerge).
As BulkMerge sends e-mails as it merges, we are finished.
MyRS = sqlCon.execute(“SELECT name, email FROM ourCustomers”)
MMerge.BulkMerge myRS, false, “mail.myDomain.com”