How to send an email to multiple recipients ? How to send an email to multiple recipients ? sql-server sql-server

How to send an email to multiple recipients ?


You need to add ; (semicolon) between e-mail addresses using string concatenation:

DECLARE @copy_to varchar(max)= @Mail2+';'+@Mail3EXEC msdb.dbo.sp_send_dbmail    @profile_name = 'mail',     @recipients = @Mail1,    @copy_recipients = @copy_to,     @body =@body ,    @subject =@subject 

You can read MSDN article here

[ @recipients= ] 'recipients'

Is a semicolon-delimited list of e-mail addresses to send the message to. The recipients list is of type varchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_dbmail returns an error.

[ @copy_recipients= ] 'copy_recipients'

Is a semicolon-delimited list of e-mail addresses to carbon copy the message to. The copy recipients list is of type varchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_dbmail returns an error.