The Result Data Newsletter   
Volume 707 - July 2007   
© Copyright 2007 Result Data Consulting, Ltd.  614-505-0770  www.resultdata.com   

    Result Data Home Page  |  Newsletter Archive  |  Upcoming Events  |  Classes & Workshops  |  Request Information
Upcoming Events:  MOBOUG: 8/1, Business Objects BI Lunch-n-Learn: 8/1, Microsoft SQL Server User Group: 9/21

Return to Newsletter Contents...

 

SQL Mail vs. Database Mail

by: Charles Tournear; Senior Consultant, MCT, MCSE, MCSD, MCDBA, CRCP

SQL Server 2005 supports the SQL Mail service that came with SQL 7.0 and SQL 2000, but it also comes with a new component Database Mail.  Both allow you to have SQL Server send emails as the result of a SQL Server Agent job process or a SQL Server Notification Service process.  Also you can use stored procedures to send emails or email the results of a query to users.

The SQL Mail component was difficult to setup because it required specific installation or configuration options in SQL Server to be setup correctly.  SQL Mail required that a Domain user account be created.  The SQL Server Service and the SQL Server Agent Service then had to be configured to start using the new user account.  Also an email client application such as Outlook or the Lotus Domino client had to be installed on the SQL Server and an email profile had to be created for the user account that SQL Server service started with.  SQL Mail only supported email clients that supported MAPI 1.0.

Database Mail does not require that a MAPI client application be installed on the SQL Server.  Database Mail uses the standard Simple Mail Transfer Protocol (SMTP) to send mail.  Database Mail is not active by default.  To use Database Mail, you must explicitly enable Database Mail using the SQL Server Surface Area Configuration tool, or the Database Mail Configuration Wizard. The Database Mail component that delivers e-mail runs outside of SQL Server, in a separate process. SQL Server will continue to queue e-mail messages in the msdb database even if the external process stops or fails.  The queued messages will be sent once the outside process or SMTP server comes online.  

A Database Mail profile allows you to specify more than one SMTP server.  Should an SMTP server be unavailable, mail can still be delivered to another SMTP server.  Database Mail allows you to create multiple profiles within a SQL Server instance.  When sending an email you have the option to choose the profile that Database Mail will use when you send the message.  Each profile can contain multiple failover accounts.  You can configure different profiles with different accounts to distribute e-mail across multiple e-mail servers.

To send a Database Mail message, you must be a member of the DatabaseMailUserRole database role in the msdb database.  Database Mail keeps copies of messages and attachments sent in the msdb database. You can easily audit Database Mail usage and review the retained messages.

While the help files state that email can be sent in HTML format, there was an issue with the sp_send_dbmail stored procedure in the msdb database that made attachments and messages formatted as HTML to be sent in Unicode format which most HTML readers don’t support.  This was fixed in Service Pack 2.

Database Mail Configuration Wizard provides a convenient way to manage Database Mail configuration objects. Database Mail Configuration Wizard performs these tasks:

  • Set up Database Mail
  • Manage Database Mail accounts and profiles
  • Manage profile security
  • View or change system parameters

The Set up Database Mail option guides you through all of the tasks required to set up Database Mail for the first time.  The other options help you accomplish specific set up and maintenance tasks.  To start the Database Mail Configuration Wizard right-click Database Mail under Management in the SQL Server Management Studio and choose Configure Database Mail.

Select the task that you wish to perform.

Select Configuration Task Pic

To set  up Database mail you must have at least one Profile with at least one account.

Give the new profile a name and click Add to add a new SMTP account.

New Profile Pic

In the account properties you can specify an Email Address, Display Name, Reply information and the server name that manages the Email address.  You can also select the type of authentication used by the Email address.

New Account Pic

On some systems I’ve had the wizard lockup and not allow me to add new accounts.  If this happens use the stored procedure “sysmail_add_account_sp” in the msdb database to add an account and then rerun the wizard to add the existing account to a profile.

Database Mail provides more flexibility in configuration, failsafe protection, and email protection through mail queues than was provided by SQL Mail.  If you are still using the SQL Mail component then you should strongly consider moving to the Database Mail component, especially since SQL Mail is considered a deprecated component and may not exist in the next version of SQL Server.

Go to Top  |  Return to Newsletter Contents

 

The Result Data Newsletter is published approximately once a month to share the latest information on business intelligence, data management and CRM. There should be a link below to allow you to change or remove yourself from our list. We take your requests very seriously. If you have any difficulty please contact us at 614-505-0770 and we will make sure that your request is handled properly. This is not intended to be an unsolicited message and you can reach us in person if needed.

© Copyright 2007 Result Data Consulting, Ltd. - All Rights Reserved
All trademarks and copyrights are the property of their respective owners. This information is provided without warranty.
Announcements
Next MOBOUG Meeting
The next Mid-Ohio Business Objects User Group (MOBOUG) meeting is August 1st, 2007.  Call 614-505-0770 or click here to reserve your seat.
Next Business Objects BI Seminar is a Lunch-n-Learn
Join us for a lunch-n-learn after the MOBOUG meeting on August 1st.  Call 614-505-0770 or click here to reserve your seat.
Summer Training Special
Beat high gas prices with Result Data Training.  Schedule and attend any public training class now through September and receive a FREE fuel card for up to $200 (restrictions apply).  Call 614-505-0770 for further details and restrictions.
Next Microsoft Data Management & BI Seminar
The next free Microsoft BI seminar on is Sept. 21, 2007.  Call 614-505-0770 or click here to reserve your seat.
Looking for a Few Good Men and Women
Join our award winning team of Business Intelligence consultants and .Net Software developers.

Send your resume and salary requirements to:
jobs@resultdata.com