Lets discuss about the steps involved in configuring the Database Mail in your database. PFB the steps involved.
- First connect to SSMS (Sql Server Management Studio) and select Management folder in Object explorer.
- Right click on “Database Mail” option and select “Configure Database Mail” option.
- When the Welcome Wizard opens click NEXT.
- Select the option “Select database mail by performing the following tasks” and click NEXT.
- Provide Profile Name and Select ADD to add a new profile.
- Here you need to provide all the SMTP settings as shown below.
- Once the details are provided correctly then select OK and then you can see a new profile created. Check the same to set as default and click NEXT .
- Continue clicking NEXT until you reach the last page and Click FINISH. You can see configuration status as shown below.
- Now the configuration part is set. Now to configure EMail in DB, go to Query analyzer and execute the following code.
sp_CONFIGURE ‘show advanced’, 1
sp_CONFIGURE ‘Database Mail XPs’, 1
- Once setup is done, we are ready to test our mails. PFB the code to be used to check the same.
EXEC sp_send_dbmail @profile_name=’MailServer’,
@body=”This is to test Database Mail.
This is it. You can use the following queries to check the status of the mail sent.
SELECT * FROM sysmail_mailitems
SELECT * FROM sysmail_sentitems
SELECT * FROM sysmail_log
Hope this helps you .. Enjoy coding guys !!
Roopesh Babu V