Development resources, articles, tutorials, code samples, tools and downloads for ASP.Net, SQL Server, Reporting Services, T-SQL, Windows, AWS, SAP HANA and ABAP
Send SQL Mail using CDONTS.NewMail in SQL Server 2008
Summary :
SQL developers can send e-mail from SQL Server using CDONTS or CDOSYS.
Although SQL Server 2005 introduced Database Mail for sending emails from SQL Server, the old school is still common among SQL Server administrators and t-sql developers.
Let's make an example and remember how CDONTS can be used along with SQL Server OLE Automation stored procedures.
Microsoft SQL Server 2005 has new tools for SQL Server database administrators and for SQL developers to send email from SQL Server.
SQL Server 2005 has introduced SQL Server Database Mail with SMTP support for enabling developers send emails using t-sql code.
The only requirement for Database Mail in SQL Server 2005 or SQL Server 2008 is an SMTP server.
After you configure Database Mail in SQL Server, t-sql developers can use sp_send_dbmail system stored procedure to send e-mail from SQL Server.
if you get the following errors when you execute the SQL mail send script given in this t-sql tutorial, follow the solution steps in order.
SOLUTION
When you execute the above t-sql configuration script, you may get the following error message that is pointing to configuration option 'Ole Automation Procedures' does not exist, or it may be an advanced option.
--Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
--The configuration option 'Ole Automation Procedures' does not exist, or it may be an advanced option.
The above error message is actually not because of 'Ole Automation Procedures' configuration option does not exist, it is beacause an SQL Server configuration advanced option.
So sql administrators should first set the 'show advanced options' configuration option before trying to change 'Ole Automation Procedures' option.