Starting with SQL Server 2005, Database Mail is no longer required to use MAPI client in order to run. You can now setup Database Mail to use Simple Mail Transfer Protocol (SMTP) to send mail from your database engine. Below is a script I have used to setup on my SQL Server 2005, but you should also be able to use the same script on the newer version of SQL Server 2008.
You may also use the built in Database Mail configuration wizard in Management Studio, under your instance’s Management folder, by right clicking on Database Mail, and selecting Configure Database Mail. (I may include another article later with screenshots on how to setup database mail using the wizard).
Before you run the script, you need to make sure that Database Mail is enabled for your database instance. You can enable that by going into your SQL Server surface area configuration application, under database engine -> database mail, and check the Enable Database Mail stored procedures option.
The first step is to setup a new profile:
-- Create new profile |
Once the profile is created and set as default, create a new account:
|
NOTE: Check with your mail provider for you e-mail server settings. Also, make sure that the port you are using is open and not blocked by a firewall or other security application. You may receive Time Out errors if the port is not open in your mail log file.
Now add the account to the profile:
|
You can now test sending an e-mail from your newly setup database mail by using the sp_send_dbmail stored procedure using something like this:
|
Please let me know what you think.
PS: All scripts and code is offered ‘as is’, and you are responsible for any use of it. You should do your own testing before using it.
0 comments:
Post a Comment