Home > DeveloperSection > Beginner > Database Mail in SQL Server

Database Mail in SQL Server


MSSQL Server Database  MSSQL Server  SQL  SQL Server 2008 
Ratings:
0 Comment(s)
 1544  View(s)
Rate this:

Database Mail in SQL Server

In this article, I’m explaining how to setup database mail in sql server.

Database mail is used to send the email using SQL Server. it is replacement of SQLMail of SQL Server earlier version. Database Mail has many enhancement over SQLMail. Database Mail is based on SMTP (Simple Mail Transfer Protocol) and also very fast and reliable where as SQLMail is based on MAPI (Messaging Application Programming Interface). Database mail depends on Service Broker so this service must be enabled for Database Mail. Database Mail can be encrypted for additional security

Setup Database Mail

You can find the database mail in sql server under the management like this:

sqlServer1.png

Right click on database mail and select configure database mail.

 

sqlServer2.png

sqlServer3.png

sqlServer4.png

sqlServer5.png

sqlServer6.png

sqlServer7.png

sqlServer8.png

sqlServer9.png

sqlServer10.png

sqlServer11.png

sqlServer12.png


To Send a mail from Database Mail


sqlServer13.png

sqlServer14.png

If you want to send mail from the code:

use msdb

go

EXEC msdb.dbo.sp_send_dbmail

@profile_name = 'TestingDatabaseMail',

@recipients = 'praveshsinghfaq@gmail.com',

@subject = 'Test Mail',

@body = 'Testing E-Mail';

sqlServer15.png

 


Don't want to miss updates? Please click the below button!

Follow MindStick