How to Send E-Mail in SQL Server

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

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='[email protected]',
@subject='Test message',
@body='This is the body of the test message.
Congrates Database Mail Received By you Successfully.'

Output

Clipboard04.jpg


© 2020 DotNetHeaven. All rights reserved.