In this article I will explain with an example, how to send email to multiple recipients using sp_send_dbmail in
SQL Server.
This article is applicable to following
SQL Server versions i.e. 2008, 2008R2, 2012, 2014, 2016, 2017, 2019 and 2022.
Unblocking the sp_send_dbmail Stored Procedure in SQL Server
Configure SQL Server for sending emails
Then, you will need to configure
SQL Server for sending emails from Database.
Sending email to multiple recipients in SQL Server
Once the
SQL Server Database is configured for sending emails, you are now ready for sending email to multiple recipients.
In order to send email to multiple recipients, a semicolon-delimited (;) list of email addresses need to be specified in the @recipients parameter.
To send an email, simply copy, paste, edit (according to your settings) and execute the following SQL query.
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Mudassar_Email_Profile'
,@recipients = 'recipient1@gmail.com;recipient2@gmail.com'
,@subject = 'Email from SQL Server'
,@body = 'This is my First Email sent from SQL Server :)'
,@importance = 'HIGH'
GO
Once executed, the following messages will appear which confirms, your email has been queued.
Checking Emails Status email sent with query results as attachment
Finally, to find the status of emails whether they are not sent, sent or failed, please refer my article
Find email sent status.
Screenshots
Recipient1
Recipient2
Downloads