Regarding sending mail

  • How to send mail as HTML in sql server 2005?

  • See BOL for more examples -

    DECLARE @EmailRecipients nvarchar(MAX), @EmailSubject nvarchar(MAX), @tableHTML nvarchar(MAX)

    SET @EmailRecipients = 'thomas_bollhofer@symantec.com'

    SET @EmailSubject = 'Sample HTML Test at ' + CONVERT(CHAR(10),GETDATE(),101) + ' @' + CONVERT(CHAR(8),RIGHT(GETDATE(),7))

    SET @tableHTML =

    N' ' +

    N'

    ' +

    N' ' +

    N' ' +

    CAST ( ( SELECT td = @@ServerName,'',

    td = [name],''

    FROM master.sys.databases WITH(NOLOCK)

    WHERE name NOT IN ('master','model','msdb', 'tempdb','distribution')

    ORDER BY name ASC

    FOR XML PATH('tr'), TYPE

    ) AS NVARCHAR(MAX) ) +

    N' ' ;

    EXEC msdb.dbo.sp_send_dbmail @recipients=@EmailRecipients

    ,@subject = @EmailSubject

    ,@body = @tableHTML

    ,@body_format = 'HTML'

    ,@importance = 'Normal';

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply