SQL Server‎ > ‎

Send an email with sql code

You must first configure Database Mail in SQL Server.    Once you do that, you can send an email at anytime using this syntax:
 
 
EXEC msdb.dbo.sp_send_dbmail @profile_name='Devin Johnson',
 @recipients='djohnson@dyntools.com; djohnson@icbconsulting.com',
 @subject='Test email',
 @body='This is an example email.'
 

To make it an HTML formatted email, add:

@body_format='HTML'