![]() |
A MAPI free world! |
|
Home About me and Nucleus Partners Links Articles, tips etc. My blog Microsoft articles Newsgroups Course demo files Sync logins SMTP Alerter ![]() |
Overview The mail support that ships with SQL Server up to SQL Server 2000 uses MAPI. Now, MAPI can be fine for an interactive mail client, but it is sometimes a mess to setup and get working with SQL Server. Important notice As of SQL Server 2005, we have Database Mail. This is an email implementation that doesn't use MAPI, it uses SMTP directly. Read about "Database Mail" and sp_send_dbmail in Books Online. More information You send email from T-SQL in SQL Server using xp_sendmail. SQL Server Agent can also send email: notifications after job executions and also for event and performance condition alerts. However, above uses MAPI. In order to get that working, you need to install Outlook on the SQL Server machine (I recommend Outlook 2000, I've had problems with 2002 and 2003). You then need to login on the SQL Server machine using the SQL Server and Agent service account and create the mail profile. And finally specify this mail profile in Enterprise Manager for both SQL Server and SQL Server Agent. Below you find recommendations and tips on how to use email from SQL Server and SQL Server Agent without using MAPI or Outlook. Sending email from SQL Server This is the easy one. Just download and install xp_smtp_sendmail from SQLDev.Net. This uses direct SMTP communication and doesn't require any MAPI or Outlook installation at all. Information about how to install and use xp_smtp_sendmail can be found at the SQLDev.NET web site. Job notifications from SQL Server Agent This is also quite straight-forward. Download and install xp_smtp_sendmail from SQLDev.Net. You don't use the operators or mail support in SQL Server Agent. Instead, you create a couple of extra job steps in your job, used to finish off the job processing. Say you have a job with three job steps, and you have default flow control for each step: As long as it is success, you continue to next step. If you have a failure, the job ends and reports failure.
This way you will receive an email each time the job was executed, the subject states whether it was success of failure and attached to the email you have a file with all output from the commands you executed - including error messages! Event alert notifications from SQL Server Agent Use the "Db Maint SMTP Alerter" from Db Maint. |