'SQL sending email with data
I am trying to send a table via email in a table like shape. What I mean is to style nicely the text that I am receiving in email, because now it looks ugly, not like a table. Any help would be much appreciated.
ALTER PROCEDURE [dbo].[testEmail]
AS
BEGIN
DECLARE @SubjectText VARCHAR(100) = 'Day ' + CONVERT(VARCHAR,(CONVERT(DATE,GETDATE())))
DECLARE @tab char(1) = CHAR(9);
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@query = 'SELECT IDDruzyny, nazwa FROM TEST.dbo.Druzyna',
@body = '
<html>
<body>
<br/><b><font color=red>Hiho</font></b>
</body>
</html>
',
@Body_format = 'HTML',
@subject = @SubjectText,
@profile_name = 'SIT',
@recipients = '[email protected]',
@attach_query_result_as_file = 0,
@query_result_separator = @tab,
@query_result_header = 1
END
END
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


