RE: [Emerald] rebatch behind the scenes .... ?

Nathan Haywood ( (no email) )
Thu, 10 Jun 1999 11:09:37 -0400

This will only work for customers with email addresses defined in the Email
field. What about those that are constructed by Username@Domain? Many ISPs
work that way. This script also does nothing to limit who gets the message.
I thought the point was to email people with declined credit cards...

-----Original Message-----
Subject: Re: [Emerald] rebatch behind the scenes .... ?
From: "Dan Tang" <>
Date: Thu, 10 Jun 1999 21:40:33 +0800

A store procedure in SQL 7.0 for you

declare curMailer INSENSITIVE cursor
for select email,firstname,lastname
from subaccounts
where datalength(email)>0
declare @email varchar(50)
declare @FirstName varchar(50)
declare @lastName varchar(50)
declare @MsgBody varchar(2000)

open curMailer
fetch next from curMailer into @email,@firstname,@Lastname
while @@FETCH_STATUS=0
Select @MsgBody='Dear ' + @FirstName + ' ' + @LastName + ',' + char(13)
select @MsgBody='Your main message here' + char(13) + char(13)
select @MsgBody='Regards,'+ char(13) + char(13)
select @MsgBody='Your title'
exec master..xp_sendmail @recipients=@email,
@subject='Your subject',
fetch next from curMailer into @email,@firstname,@Lastname
close curMailer
deallocate curMailer

To test it, run this on SQL7.0 QueryAnalyzer, replace @email the
@receipients=@email with your email address like that

Because this is a store procedure, you can acctually set up a ASP page,
which you can type in the message and let the Web Server and SQL 7.0 handle
the rest.


Dan Tang
Network Operation
Domain Internet Access
Sign Up a Dial up account at and get connect right
Join the Emerald ASP Addon Product mailing list
by sending email to with message body SUBSCRIBE