Setting Database Mail on SQL Server 2005/2008
I was creating a web service that processes data and saves into relevant tables. Should there be any error in the process, an error record was created. Although there are many ways to be alerted when an error occurred, I felt that in this case it was more appropriate to use a Stored Procedure to send an error email.
In SQL Server 2005/2008, the Database Mail feature need to be setup. The Database Mail feature allows SQL Server to send emails to end users. The only pre-requisite is to have an SMTP server available.
Database Mail is now configured and ready for use. Let’s send a test mail to confirm that it is configured properly.
Now that we have Database Mail working, we can use the following syntax to send email:
EXEC [msdb]..[sp_send_dbmail] @profile_name = 'testProfile', @recipients = 'To@email.com', @subject = 'Error Message', @body = 'Include error message', @body_format = 'HTML'
















