Is it possible to use a SELECT statement for the @recipients field
with xp_sendmail? What I want to do is get a list of email
addresses from a table and send mail to them with xp_sendmail.
Thanks,
Steve Renaker
srenaker@alexa.com
Printable View
Is it possible to use a SELECT statement for the @recipients field
with xp_sendmail? What I want to do is get a list of email
addresses from a table and send mail to them with xp_sendmail.
Thanks,
Steve Renaker
srenaker@alexa.com
I don't think you can use a SELECT statement there.
One really convoluted approach I came up with when trying to do a similar thing was something like this:
declare @i int, @max_i int, @address varchar(255)
SELECT
identity(int,1,1) as id, email
INTO #email
FROM
MyTable
WHERE
'.....'
AND email is not null
select @i = 1, @address = ''
select @max_i = (select max(id) from #email)
while @i <= @max_i
BEGIN
select @address = @address + (select email from #email where id = @i) + ';'
select @i = @i + 1
END
exec master..xp_sendmail @recipients=@address, @message='this is a test message', @subject='hello..'
Good luck,
Donnie
------------
Steve Renaker at 9/21/99 2:28:21 PM
Is it possible to use a SELECT statement for the @recipients field
with xp_sendmail? What I want to do is get a list of email
addresses from a table and send mail to them with xp_sendmail.
Thanks,
Steve Renaker
srenaker@alexa.com