Monday, August 12, 2019

Sql Server: Send test email with Database Mail

In the previous article I have explained how to configure databasemail using wizard in Sql Server. Now in this article I am going to explain how we can send test email with Database mail from Sql Server.

We have 2 different ways to send test email. One using Management option and 2nd using system procedure.

Method 1: Send email using Sql Server Management option
Kindly follow the below given steps to send test email with database mail.

STEP 1: Connect to Database engine. In object explore expand the Management option. Right click on Database Mail and select send test E-mail option.

Sql Server: Send test email with Database Mail


STEP 2: Send test E-mail popup will be open. You can see the 4 options are available are there:

Database Mail Profile: Select the database mail profile from which you want to send test email.
To: Enter the email address on which want to send test email.
Subject: There is already a default subject, if want to change you can.
Body: In body option, also have default text. If you want to send any relevant message can type in given text area.

Sql Server: Send test email with Database Mail

STEP 3: Click on Send Test E-Mail button. You will get a dialogue box with message for confirmation test email is received or not.

Sql Server: Send test email with Database Mail


Result (Test email received):
Sql Server: Send test email with Database Mail



Method 2: Send email using Store procedure

We use the sp_send_dbmail system procedure to send an email. As you can see below I have entered the database mail profile name, recipients email address, subject and message (body).

use msdb

EXEC sp_send_dbmail @profile_name='aspmantra email profile',
@recipients='saklanivijay87@gmail.com',
@subject='Test Email',
@body='Welcome to Sql world'


Output(Test email received):


Sql Server: Send test email with Database Mail



No comments:

Post a Comment