How to configure emails in MSSQL server and how to Read Email logs,Email operator,how to setup SMTP

Опубликовано: 28 Февраль 2025
на канале: DBMS Concepts
2,965
46

MSSQL ADMINISTRATION IN HINDI | MSSQL DBA CLASS IN HINDI | LEARN MSSQL IN HINDI Step by step database email configuration .
How to configure Database Mail in SQL Server step by step using GUI on sql server 2019

Configuring Database Mail
To create a Database Mail profile, we can use either the Database Mail Configuration Wizard or T-SQL code. Using Configuration Wizard is easier, but keep in mind that Database Mail is turned off in SQL Server Express editions however you can always use developer edition for all features same like enterprise edition .

generally , need to do is go in Object Explorer, connect to the SQL Server instance we want to configure Database Mail on and expand the server tree. Then expand the Management node and double-click Database Mail or right-click and choose Configure Database Mail to open the Database Mail Configuration Wizard:
Since we are using Microsoft SQL Server 2019 Developer edition and email option is there as per above steps. also you can enable the email in case of disabled using below command.

To enable Database Mail, use following code:

sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO
To create a new Database Mail profile named ‘Autoemail’ we will use the sysmail_add_profile_sp stored procedure and the below code:

-- Create a Database Mail profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'Autoemail',
@description = 'Profile used for sending outgoing notifications using Gmail.' ;
GO

to check email logs using TSQL
SELECT * FROM msdb.dbo.sysmail_event_log;
To troubleshoot this further, we need to approach the problem from another perspective.

So far in troubleshooting, we have verified the following general steps:

Database Mail is enabled
The user is properly configured to send Database Mail
Sending a test e-mail doesn’t work


Please get subscribe for latest video in DBA in HINDI and ask the questions in the comment box.