How to Send E-Mail in SQL Server

In this article I am going to explain how to send E - Mail in SQL Server.
  • 2327

Introduction

In this article I am going to explain how to send E-Mail in SQL server. You can send E-Mail from SQL server. Before sending e-mail we have to configure e mail in SQL server.  Here I am explaining how to send E Mail in SQL server.

To send E mail we need to enable the Database Mail XPs parameter through sp_configure stored procedure.

Example

sp CONFIGURE 'show advanced', 1
GO
RECONFIGURE
GO
sp_CONFIGURE 'Database Mail XPs', 1
GO
RECONFIGURE
GO

Output

Clipboard02.jpg

To send E- Mail we use fallowing statement

Example

USE msdb
GO
EXEC sp_send_dbmail @profile_name='vipendra',
@recipients='verma.vipendra@gmail.com',
@subject='Test message',
@body='This is the body of the test message.
Congrates Database Mail Received By you Successfully.'

Output

Clipboard04.jpg


© 2019 DotNetHeaven. All rights reserved.