How to configure Database mail in SQL Server

   11/23/2021 6:55:49 PM     configure database mail in SQL Server Send Mail SQL Server T-SQL Query     0

Share us on:

Linkedin GooglePlus

Send Mail from Database, This is a very important feature of SQL Server Database
Microsoft SQL Server provides users to send mail from the database.

Hi, I am Shubham Kumar, I will explain and implement how to configure and send mail from SQL Server.

Sending mail from the database is very easy, firstly you need to understand how to configure settings for SQL Server mail then you can easily send mail easily from the database.


Here, I am going to explain with an example, how to send mail from an SQL Server.

There are two ways to configure settings for sending mail from the SQL Server Database

  1. Database Mail Configuration Wizard 
  2. SQL Script 

Now, I am Configure settings for sending mail from Database

 

Method #1: Database Email Configuration Wizard

Step #1: Open Management Folder and Right Click On Database Mail and select Configure Database Mail from the given options

 

Open-Management-Folder

 

Step #2: If you select the option "Configure Database Mail' and you will get the welcome Window popup and then click "Next".

welcome-Screen

 

Step #3: The following screen will appear for settings, If you did not create any profile then you select "Set up Database Mail by performing" and click "Next".


If you have already created a profile for SQL mail then you want to modify the settings then you can choose "Manage Database Mail Account and profiles" or "View or Change System parameters".

 

profile-for-SQL-mail

 

Step #4: you will see the following screen because it is not enabled. if you click "Yes" then it makes enable for Database mail. If Database Mail has already been enabled this screen will not appear

 

Enable-Database-Mail

 

Step #5: If you want to create a profile need to Enter a name for the Profile and also a description(not mandatory) and click "Add"

 

Create-Profile

 

Step #6: You will get The following screen will appear.  Fill out all mandatory details for your mail account that will be used to send out emails from SQL Server.  When you are done click "OK".

 

Database-Mail-Account

 

Step #7:  After that your screen will show added SMTP details, if you want to go with this profile then click on "next"

 

Added-Profile-Screen

 

Step #8:  you will see the following screen, There is an option to make the profile public or private and default profile. 

If you choose public then it can be accessed by all users.

 Click on the checkbox to allow this to be a public profile and select "Yes" for the default profile and then click "Next".

 

Make-Public-or-Private-Screen

 

Step #9: You will get The following screen has some additional parameters that can be set to control how mail is sent.  You can change the defaults settings or leave the defaults.  When you are done click "Next"

 

additional-parameters-Screen

 

Step #10: you will get A summary Details screen will appear that shows you all of the options that were selected.  If everything is OK then click "Finish" or click "Back" to go back and make changes.

 

summary-Details-Screen

 

Step #11: After clicking on "Finish" the next screen will show you the status of installing Database Mail. When it is completed then close this screen.

 

status-Screen

 

Step #12: If you want to send mail from Database Configuration Wizard,then right click on Database Mail and then select option Send Test E-Mail

 

Send-mail-Screen

 

Method #2: SQL Script

If you want to send mail from sql script then follow this given link

 

I hope this article will help you to learn and implement How to send mail from SQL Server if you like this article please share Us on

Shubham Kumar

Shubham Kumar is a founder of AspNetBugs, .NET Team Leader. He has very good experience with designing and developing enterprise-scale applications. He is exprience in ASP.NET MVC,ASP.NET C#, ASP.NET Core, AngularJS, Web API, EPPlus, SQL, Entity Framework, JavaScript, jQuery, Kendo, Windows services etc.