Sending Mails Via SQL-Server
Sending Mails Via SQL-Server
04 juillet 2017 1
I. Introduction:................................................................................................................................ 3
II. Advantages .................................................................................................................................. 3
III. Configuration........................................................................................................................... 3
1- Configure the account and the profile : ................................................................................. 3
2- Send the email using the procedure msdb.dbo.sp_send_dbmail ........................................... 4
IV. Logs Accounts and Profiles informations : .............................................................................. 4
04 juillet 2017 2
Sending Mails via SQL-Server
I. Introduction:
This topic will describe the methods that will allow us to send notifications via mails, using
only SQL Server’s Stored procedures and Triggers, and without using any third-party
applications
II. Advantages
• Notifying DBAs and other users when SQL Server Agent jobs complete, fail, or
succeed
• Sending the results of queries via email to interested individuals
• Sending alerts when certain conditions arise on my SQL Server instances
• Save a lot of time
III. Configuration
Account name
Profile name
04 juillet 2017 3
2- Send the email using the procedure msdb.dbo.sp_send_dbmail
Email recipients
Email subject
Email Body
• To troubleshoot the email sending we can consult the log using the table
msdb.dbo.sysmail_log
• To trace the different Accounts in the Database we can consult the table
msdb.dbo.sysmail_account
• To trace the different Profile in the Database we can consult the table msdb.dbo.
sysmail_profile
04 juillet 2017 4