May 9, 2008 at 8:15 am
Hi, I found (?!) a bit of code to email me a report in html format. Have played around with it and all seems fine apart from the fact that when i receive the emailed report, the data in the select query appears as a line above the 'grid' and below the title, instead of actually inside the grid!! Any pointers please!! Thank-you. Code using is....
DECLARE @tableHTML NVARCHAR(MAX) ;
SET @tableHTML =
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
cast ( (
SELECT pm_id,pm_title,pm_order,pm_last_update,usr_incident from pm_process
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N' ' ;
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQLMail',
@recipients='me@mycompany.com',
@subject = 'Work Order List',
@body = @tableHTML,
@body_format = 'HTML'
May 9, 2008 at 8:43 am
simon.letts (5/9/2008)
Hi, I found (?!) a bit of code to email me a report in html format. Have played around with it and all seems fine apart from the fact that when i receive the emailed report, the data in the select query appears as a line above the 'grid' and below the title, instead of actually inside the grid!! Any pointers please!! Thank-you. Code using is....DECLARE @tableHTML NVARCHAR(MAX) ;
SET @tableHTML =
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
N' ' +
cast ( (
SELECT td = pm_id,pm_title, '', td = pm_order, '', td = pm_last_update, '', td = usr_incident from pm_process
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N' ' ;
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQLMail',
@recipients='me@mycompany.com',
@subject = 'Work Order List',
@body = @tableHTML,
@body_format = 'HTML'
you need to do this a little different to get well formatted html code out of it like i qoted you above
May 13, 2008 at 4:49 am
Thanks very much for that, minor tweaks and works perfectly 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply