declare @body1 nvarchar(MAX)
set @body1 = N’

:: Report(1-06-2011 To 30-06-2011) ::

‘ +
N’

‘ +
N” + CAST ( ( SELECT
td = FirstName, ”,
td = LastName, ”,
td = EmailId, ”
from Users
ORDER BY FirstName ASC FOR XML PATH(‘tr’), TYPE ) AS NVARCHAR(MAX) ) +
N’

First Name Last Name Email


print @body1
EXEC msdb.dbo.sp_send_dbmail @recipients=’sunil@iglobeconsulting.com’,
@subject = ‘My Mail Test’,
@body = @body1,
@profile_name = ‘Prakash Rathod’,
@body_format = ‘HTML’ ;