Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Mail pull recipients from list

Status
Not open for further replies.

ropewrench

Programmer
Joined
Feb 20, 2005
Messages
10
Location
US
I am looking to pull recipients for xp_sendmail from a table and insert them into a varible on the @recipients. Is this possible?
The table holding the addresses is fine and inserts the specified address into the variable. However get the error:
Server: Msg 18031, Level 16, State 1, Line 0
xp_sendmail: Could not resolve recipient

-- ****** Declare and find Email Distribution List *******
declare @emaildistribution varchar(128)

select @emaildistribution = RTrim(RinAutoEmail.MailingDistribution)
FROM RinAutoEmail

use master


EXEC xp_sendmail
@recipients=@emaildistribution,

respectfully,
ropewrench
 
Never mind, found my own answer.

-- ****** Declare and find Email Distribution List *******
declare @emaildistribution varchar(128)

select @emaildistribution = RTrim(RinAutoEmail.MailingDistribution)
FROM RinAutoEmail
WHERE db.ReportName = 'BelowMin';

use master
declare @sendmail varchar(128)
set @sendmail = @emaildistribution

EXEC xp_sendmail
@recipients = @sendmail,

respectfully,
ropewrench
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top