You are on page 1of 4

SAPPL Mercedes-Benz

Société Algérienne pour la


Production de Poids Lourds de
Marque Mercedes-Benz SPA
Route Nationale N'5 Rouïba
Alger, Algérie

Sending Mails via SQL-Server

Author: ALAOUI Mohamed


Function: Ingénieur Systèmes d’information
Department : IT
Date : 04-07-2017

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

1- Configure the account and the profile :

Account name

Sender email address


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

IV. Logs Accounts and Profiles informations :

• 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

You might also like