Tutorial by Examples

This code sends a simple text-only email to [email protected] EXEC msdb.dbo.sp_send_dbmail @profile_name = 'The Profile Name', @recipients = '[email protected]', @body = 'This is a simple email sent from SQL Server.', @subject = 'Simple email'
This attaches the results of the query SELECT * FROM Users and sends it to [email protected] EXEC msdb.dbo.sp_send_dbmail @profile_name = 'The Profile Name', @recipients = '[email protected]', @query = 'SELECT * FROM Users', @subject = 'List of users', ...
HTML content must be passed to sp_send_dbmail SQL Server 2012 DECLARE @html VARCHAR(MAX); SET @html = CONCAT ( '<html><body>', '<h1>Some Header Text</h1>', '<p>Some paragraph text</p>', '</body></html>' ) SQL Server 2012 ...

Page 1 of 1