Configuring Database Mail | SansSQL

Friday, January 21, 2011

Configuring Database Mail

Database Mail in SQL Server 2005 and up is the replacement of the SQL Mail that existed in SQL Server 2000. Database Mail is more enhanced than SQL mail and does not require a MAPI mail client like outlook or outlook express installed on the system for it to work.

Here is the procedure to setup or configure the Database mail.
  1. Enable Database Mail XPs
    EXEC SP_CONFIGURE 'show advanced options',1

    EXEC SP_CONFIGURE 'Database Mail XPs',1
  2. Expand the "Management" Folder under your server. Right-Click on the "Database Mail" and Choose "Configure Database Mail"
  3. This will open up the Database Mail Configuration Wizard.
    Now in the welcome page, click "Next" and in the "Select Configuration Task" Page choose the option "Setup Database Mail by performing the following tasks" and click "Next"
  4. Now in the next page "New Profile" the wizard gives you the option to create your mail profile and Add accounts to this profile. Fill in the Mail profile details and click on "Add" button to add the Mail accounts.
  5. In the "New Database Mail Account" page, fill in the Account Name, Description, Email Address, Display Name, Reply e-mail, Exchange Server Name and its Port Number. By default the port number will be 25. If it is different for your exchange server, then you have to mention that port number here.
    Then Specify the SMTP Authentication and click "OK"
  6. Click "Next" in the resulting Page
  7. In the "Manage Profile Security" page, select the appropriate security for your profile.
    Profiles are either Public or Private. A Private Profile is accessible only to specific Users or Roles. A Public Profile allows any Users or Roles with access to msdb database to send e-mail using that profile.

  8. In the next Screen, you can configure the System Properties.
  9. After configuring the System Parameters, click "Next". In the Summary Page, the wizard will display what actions will be performed. If you are satisfied then click "Finish" else Click "Back" button and do the changes as required.

  10. Now Send a Test E-mail. Right-Click on "Database Mail" and Choose "Send Test E-Mail..."
    Now in the resulting Screen, select the "Mail Profile", enter the "To" E-Mail Address, Subject and Body and then Click on "Send Test E-Mail".

    You can also send e-mail by using the SP sp_send_dbmail which will be present in the msdb database.
    Exec msdb..sp_send_dbmail
          ,@Subject='Test Email'
          ,@Body='Test Email from my Laptop'

This article is also available in pdf format for downloading.
Please Click here to get your copy.


Raj Baraty said...

One more thing we always miss to check is - To enable the SQL Server Agent, Alert System reflecting the correct mail profiles. This helps us to setup correct email notifications to the required groups\individuals.

Huongkvb said...

Aivivu - đại lý chuyên vé máy bay trong nước và quốc tế

kinh nghiệm mua vé máy bay đi Mỹ giá rẻ

lịch bay từ california về việt nam

mua vé máy bay từ đức về việt nam

dịch vụ vé máy bay tại nga

khi nào có chuyến bay từ anh về việt nam

chuyến bay từ paris về hà nội

Chuyen bay cho chuyen gia nuoc ngoai

Post a Comment