Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Sending text and table in email message body

$
0
0

Hello,

I would like to add some text to the email message body, preferably before inserting a table. I am successfully able to send results of a select statement as shown in code below. The string showing up ring above the table is showing up formatted in a pretty big font size.

Is there a way to insert text coming from a parameter value in between the large text (already displayed) and the table ?

Please see my code for reference.

DECLARE @tableHTML  NVARCHAR(MAX) ;

		SET @tableHTML =
			N'<H1>Report Distribution Update Notification</H1>' +
			-- I'm trying to insert a string block here. The string showing here will be a combination of text + parameter value
			-- e.g: 'Some text showing up in email" + @paramter
			N'<table border="1">' +
			N'<tr><th>Type</th><th>ID</th>' +
			N'<th>ReportName</th><th>Frequency</th><th>RunReport</th></tr>' +
			CAST ( ( SELECT td = Type,       '',
							td = ID, '',
							td = ReportName, '',
							td = Frequency, '',
							td = Case When RunReport = 1 Then 'True' Else 'False' End
					  FROM #ResultSet
					  FOR XML PATH('tr'), TYPE
			) AS NVARCHAR(MAX) ) +
			N'</table>' ;

		EXEC msdb.dbo.sp_send_dbmail
			@profile_name = 'smtp.company.com',
			@recipients='t.m@company.com',
			@subject = 'Successful update of RunReport flag on attached reports',
			@body = @tableHTML,
			@body_format = 'HTML' ;

Any assistance would be much appreciated.

Thanks


Viewing all articles
Browse latest Browse all 10045

Trending Articles