0% found this document useful (0 votes)
19 views

Sending Mails Via SQL-Server

This document discusses how to send emails from SQL Server using stored procedures and triggers. It notes that this allows notifications to be sent when jobs complete or fail, query results to be emailed, and alerts sent for certain SQL Server conditions. The key steps are to configure an email account and profile, then use the msdb.dbo.sp_send_dbmail stored procedure to send emails by specifying recipients, subject, and body. Logs of emails sent and account/profile information are stored in SQL Server tables for troubleshooting.

Uploaded by

Oualid Belbrik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Sending Mails Via SQL-Server

This document discusses how to send emails from SQL Server using stored procedures and triggers. It notes that this allows notifications to be sent when jobs complete or fail, query results to be emailed, and alerts sent for certain SQL Server conditions. The key steps are to configure an email account and profile, then use the msdb.dbo.sp_send_dbmail stored procedure to send emails by specifying recipients, subject, and body. Logs of emails sent and account/profile information are stored in SQL Server tables for troubleshooting.

Uploaded by

Oualid Belbrik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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