HTML content must be passed to sp_send_dbmail
DECLARE @html VARCHAR(MAX);
SET @html = CONCAT
(
'<html><body>',
'<h1>Some Header Text</h1>',
'<p>Some paragraph text</p>',
'</body></html>'
)
DECLARE @html VARCHAR(MAX);
SET @html =
'<html><body>' +
'<h1>Some Header Text</h1>' +
'<p>Some paragraph text</p>' +
'</body></html>';
Then use the @html
variable with the @body argument
. The HTML string can also be passed directly to @body
, although it may make the code harder to read.
EXEC msdb.dbo.sp_send_dbmail
@recipients='[email protected]',
@subject = 'Some HTML content',
@body = @html,
@body_format = 'HTML';