July 17, 2013 at 11:34 am
I am trying to find an article or guide for creating an SSIS package(best method?) with a for each loop container.
I query a table, returning 5 columns, the result has the recipients email address, and name, i need to send the same email message to the entire result set.
Using sql server 2008 r2 and database mail.
do i place the send email task within the loop and somehow override the fields i want to overrride?
Changing the body of the email appears do able as i would insert that into each pass, but changing the recipient seems to be a different story.
Thanks :crazy:
July 17, 2013 at 11:57 am
You can pass the recipient list as a variable as in
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'YourProfileName',
@recipients = @emaillist,
...
This should be simple if it is a single recipient. If there are multiple recipients, you may need to construct a loop to add each recipient with a semi-colon delimiter, as in
@emaillist = @emaillist + ';' + @nextrecipient
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply