Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Configure SQL Server Database Mail

by suresh

This article shows the step by step approach to Configure SQL Server Database Mail to send Emails using your Gmail account or any other account. To Configure SQL Server Database Mail, Please select the Management Folder within the SQL Server Object Explorer, and then select Database Mail.

Configure SQL Server Database Mail 1

Right-click on the Database Mail will open the context menu. Please select the Configure Database Mail option to configure the new database Mail, or to View, Edit, Delete existing Database Mails in SQL Server.

Configure SQL Server Database Mail 2

Once you select the SQL Server Configure Database Mail option, a new wizard will open.

Configure SQL Server Database Mail 3

Configure SQL Server Database Mail

Select configuration Task: This page is used to create, or Manage Database Mails. In this example, we want to configure a new SQL Server database mail. So, please select the Set up Database Mail by performing the following tasks option

Configure SQL Server Database Mail 4

New Profile: This page to create a new profile, and to add the SMTP account. From the below screenshot you can see that, we assigned Email as the profile name, and This is an Email Configuration as the profile description. Next, click on the Add button to add new SMTP account to this profile.

Configure SQL Server Database Mail 5

Once you click on the Add button, a new window called New Database Mail Account will pop up to configure SQL Server Database Mail.

  • Account Name: A unique name for this SMTP account.
  • Description: Valid description for the above-specified account
  • Email Address: Email Id that you want to use for sending an Email. Senders Email Address.
  • Display Name: This name displayed within the sent mail.
  • Reply Email: same as Email Address
  • Server Name: valid SMTP name. If you are using Gmail, then use smtp.gmail.com, and for Windows live account use smtp.live.com, etc
  • Port Number: By default, you can use Port number 25, but for Gmail SSL, please use 587.

Next, under the SMTP Authentication section, you have to specify the Authentication details for SQL Database Mail.

  • Windows Authentication: It will use the Windows credentials
  • Basic Authentication: Always use this option. Here please specify the sender’s Email ID, password.
  • Anonymous Authentication: It will not use any authentication
Configure SQL Server Database Mail 6

From the below screenshot you can see that, we assigned MSBI as the account name, This is a Gmail Account as description, and Suresh as the display name.

Configure SQL Server Database Mail 7

After you click OK, SMTP account creation form will close

Configure SQL Server Database Mail 8

If it is your default profile, select Yes otherwise, please leave the option to default No.

Configure SQL Server Database Mail 9

Click Next button

Configure SQL Server Database Mail 10

Click on the Finish button to finish Configure SQL Server Database Mail to send emails.

Configure SQL Server Database Mail 11

Lastly, it will display the details. Please click on the Close button to close the SQL Server Database Mail Configuration wizard.

Configure SQL Server Database Mail 12

Now right-click on the Database Mail will open the context menu. This time, Please select Send Test E-Mail.. option to send Email using the SMTP account that we created earlier.

Configure SQL Server Database Mail 13

Add the mail address, Change Subject and Message Body as per your requirements. And after you complete editing, Please click the Send Test E-Mail button to send an Email.

Configure SQL Server Database Mail 14

Let me open My Gmail account

Configure SQL Server Database Mail 15

Delete SQL Server Database Mail

To delete the configured SQL Server database Email, Right-click on the Database Mail will open the context menu. Please select the Configure Database Mail option to open the wizard. And in the second Page, please select the Manage Database Mail accounts and profiles option this time.

Configure SQL Server Database Mail 16

Manage Profiles and Accounts: Use this page to Create, View, Edit, or delete the accounts and profiles.

  • Create a new account: This option is used to create a new account.
  • View, Change, or Delete an existing account: As its name suggests, we can view, edit or delete existing accounts.
  • Create a new profile: Use this option to create a new profile.
  • View, Change, or Delete an existing profile: As its name suggests, we can view, edit, or delete existing profiles.

Before you start deleting the Account, you have to delete the profiles linked to that account. So, we are selecting the last option to delete the profile.

Configure SQL Server Database Mail 18

From the drop-down list, please select the Profile Name and click the Delete button to delete the profile.

Configure SQL Server Database Mail 19

After deleting the profile, please select the second option to delete the Configured SQL Server Database Mail account

Configure SQL Server Database Mail 17

Or you can use the following SQL Query to delete the account

EXECUTE msdb.dbo.sysmail_delete_account_sp 
 @account_name = 'MSBI' ;

Placed Under: SQL

  • Install SQL Server
  • Install SQL Management Studio
  • Uninstall Management Studio
  • Install AdventureWorks Database
  • SQL Management Studio Intro
  • Connect SQL with sqlcmd utility
  • SQL Attach Database
  • SQL Detach Database
  • SQL Restore Database
  • Restore Database using BAK
  • SQL Rename Database with Files
  • Get SQL Database Names
  • SQL Create Table
  • SQL Rename Table
  • SQL Alter Table
  • SQL Add Column
  • SQL Rename Column
  • Get SQL Table Names in a DB
  • Find SQL Table Dependencies
  • Rename SQL Table & Column
  • SQL Global & Local Temp Table
  • SQL Table Variable
  • SQL Derived Table
  • SQL DATALENGTH
  • SQL Data Types
  • DML, DDL, DCL & TCL Cmds
  • SQL Query Builder
  • SQL ALIAS
  • SQL SELECT Statement
  • SQL SELECT DISTINCT
  • SQL SELECT INTO Statement
  • SQL INSERT Statement
  • SQL INSERT INTO SELECT
  • SQL BULK INSERT or BCP
  • SQL UPDATE Statement
  • SQL UPDATE from SELECT
  • SQL DELETE Statement
  • SQL TRUNCATE Table
  • SQL CASE Statement
  • SQL MERGE Statement
  • SQL Subquery
  • SQL CTE
  • SQL PIVOT
  • SQL UNPIVOT
  • SQL Clauses Examples
  • SQL TOP Clause
  • SQL WHERE Clause
  • SQL ORDER BY Clause
  • SQL GROUP BY Clause
  • SQL HAVING Clause
  • SQL Primary Key
  • SQL Foreign Key
  • SQL Referential Integrity
  • SQL Check Constraint
  • SQL Unique Constraint
  • SQL Default Constraint
  • SQL Clustered Index
  • SQL Non Clustered Index
  • SQL Filtered Indexes
  • SQL COALESCE Function
  • SQL IS NOT NULL
  • SQL IS NULL Function
  • SQL ISNULL
  • SQL JOINS
  • SQL CROSS JOIN
  • SQL FULL JOIN
  • SQL SELF JOIN
  • SQL Outer Joins
  • SQL Cross Join Vs Inner Join
  • SQL LEFT JOIN
  • SQL RIGHT JOIN
  • SQL AND & OR Operators
  • SQL Arithmetic Operators
  • SQL BETWEEN Operator
  • SQL Comparison Operators
  • SQL LIKE
  • SQL EXCEPT
  • SQL EXISTS Operator
  • SQL NOT EXISTS Operator
  • SQL INTERSECT
  • SQL IN Operator
  • SQL NOT IN Operator
  • SQL UNION
  • SQL UNION ALL
  • SQL IF ELSE
  • SQL ELSE IF
  • SQL WHILE LOOP
  • SQL Nested While Loop
  • SQL BREAK Statement
  • SQL CONTINUE Statement
  • SQL GOTO Statement
  • SQL IIF Function
  • SQL CHOOSE Function
  • SQL Change Data Capture
  • SQL Table Partitioning
  • SQL Table Partition using SSMS
  • SQL TRY CATCH
  • SQL VIEWS
  • SQL User Defined Functions
  • SQL Alter User Defined Functions
  • SQL Stored Procedure Intro
  • Useful System Stored Procedures
  • SQL SELECT Stored Procedure
  • SQL INSERT Stored Procedure
  • SQL UPDATE Stored Procedure
  • Stored Procedure Return Values
  • Stored Procedure Output Params
  • Stored Procedure Input Params
  • Insert SP result into Temp Table
  • SQL Triggers Introduction
  • SQL AFTER INSERT Triggers
  • SQL AFTER UPDATE Triggers
  • SQL AFTER DELETE Triggers
  • SQL INSTEAD OF INSERT
  • SQL INSTEAD OF UPDATE
  • SQL INSTEAD OF DELETE
  • SQL STATIC CURSOR
  • SQL DYNAMIC CURSOR
  • SQL FORWARD_ONLY Cursor
  • SQL FAST_FORWARD CURSOR
  • SQL KEYSET CURSOR
  • SQL TRANSACTIONS
  • SQL Nested Transactions
  • SQL ACID Properties
  • Create SQL Windows Login
  • Create SQL Server Login
  • SQL Server Login Error
  • Create SQL Server Roles
  • SQL Maintenance Plan
  • Backup SQL Database
  • SQL Ranking Functions Intro
  • SQL RANK Function
  • SQL PERCENT_RANK Function
  • SQL DENSE_RANK Function
  • SQL NTILE Function
  • SQL ROW_NUMBER
  • SQL Aggregate Functions
  • SQL Date Functions
  • SQL Mathematical Functions
  • SQL String Functions
  • SQL CAST Function
  • SQL TRY CAST
  • SQL CONVERT
  • SQL TRY CONVERT
  • SQL PARSE Function
  • SQL TRY_PARSE Function
  • SQL Calculate Running Total
  • SQL Find Nth Highest Salary
  • SQL Reverse String
  • SQL FOR XML PATH
  • SQL FOR XML AUTO
  • SQL FOR XML RAW

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy