Database mail to multiple recipient from table | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Database mail to multiple recipient from table

I am using database mail to send emails to our Lotus Notes SMTP server using sp_send_dbmail. I want to accomplish the following. I have maintained department-wise users email address in one table . Now I want to send mail to one particular department and there can be 1-15 users as recipient for that mail. How can I do that using sp_send_dbmail?

from a script read the table and combine the list of users with ; eg:
[email protected];[email protected] —————————————-
Contributing Editor, Writer & Forums Moderator
http://www.SQL-Server-Performance.Com Visit my Blog at
http://dineshasanka.spaces.live.com/

Can you guide further, Cuz the script I want to write but so far not much success.
DECLARE @email VARCHAR(4000)
SET @email = ”
SELECT @email = RTRIM(@email) + RTRIM(email) + ‘;’
FROM Users
WHERE email <> ” AND DepCode = ‘A’
PRINT @email
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = ‘custoerders’,
@description = ‘Customer Address Account’,
@email_address = @email
@mailserver_name = ‘mail.anywhere.com’ —————————————-
Contributing Editor, Writer & Forums Moderator
http://www.SQL-Server-Performance.Com Visit my Blog at
http://dineshasanka.spaces.live.com/

Thanks, i will test & confirm.
It works just fine. thanx.
]]>