' First
we will create a message object that will serve as a
' template for the merge.
'
The merge fields are marked with %% in the front and in the
' end.
' Note how we use
merge fields even in the addRecipient method
set msgTemplate =
Server.CreateObject( "JMail.Message" )
msgTemplate.From = "me@myDomain.com"
msgTemplate.FromName = "Mailinglist info!"
msgTemplate.AddRecipient
"%%EMail%%", "%%Name%%"
msgTemplate.Subject = "Hi %%Name%%"
msgTemplate.Body = "Hello %%Name%%, you are my
favorite website visitor!"
' There,
our message template is done. Next we create the mailmerge
object.
set mMerge = Server.CreateObject(
"JMail.MailMerge" )
' Now,
tell mailMerge to use the template we created earlier
mMerge.MailTemplate = msgTemplate
' Since we are sending the messages directly, we
want to catch the messages
' where the sending
fails.
mMerge.ContinueOnFail = True
' Okay lets do the merge. As we do an ADO resultset
merge, we do not need to
' specify each merge
variable.
' The myRS is assumed to hold a ADO
recordset.
' If you
have many recipients, you really should enque the emails instead of
' sending them directly
'
MailMerge.BulkMerge myRS, true, "c:\inetpub\mailroot\pickup"
' The BulkMerge() method
automatically sends/enques our emails, so we
'
do not need to use the send() method.
mMerge.BulkMerge myRS, false, "smtp.example.com"
' Now we get access the log and loop through the
messages
Set list = mMerge.Log
For i = 0 To list.Count -
1
' Get the current
JMail.MailMergeResult object
Set res = list.Item(i)
' Here you might do
something more useful than just outtputing
the Email
' address. Maybe you can
update the database.
Response.Write
"<pre>" & res.EMail & "</pre>"
Next
' Thats it! One template, a workload of emails.