Example of Send Email in Tabular Format HTML Using SQL Server Database Mail

1. Make sure for Database Mail is running well 2. Example: --------------------------------------------------------------------------------code:start ---------------------------------------------------------------------------DECLARE @xml NVARCHAR(MAX) DECLARE @body NVARCHAR(MAX) SET @xml = CAST(( SELECT [DRIVE] AS 'td','' ,[DISKSPACEFREE] AS 'td','' ,[DATABASENAME] AS 'td','' ,[FILENAME] AS 'td','' ,[FILETYPE] AS 'td','' ,[FILESIZE] AS 'td','' ,[SPACEFREE] AS 'td','' ,[PHYSICAL_NAME] AS 'td' FROM Temp_Free_Space_Of_Database ORDER BY DISKSPACEFREE, SPACEFREE DESC FOR XML PATH('tr'), ELEMENTS ) AS NVARCHAR(MAX))

SET @body ='

Alerts: Free Space of Database

' SET @body = @body + @xml +'
DRIVE DISKSPACEFREE DATABASENAME FILENAME FILETYPE FILESIZE SPACEFREE PHYSICAL_NAME
'

EXEC msdb.dbo.sp_send_dbmail @profile_name = 'SQLAlerts', --<<<<< replace with your SQL Database Mail Profile @body = @body, @body_format ='HTML', @recipients = '[email protected]', --<<<<< replace with your email address @subject = 'Alerts: About Free Space of Database' ; --------------------------------------------------------------------------------code:end ----------------------------------------------------------------------------

1

3. Result Messages: Mail queued.

4. Check in Inbox of Mail

Source: http://www.mssqltips.com/sqlservertip/2347/send-email-in-a-tabular-format-using-sql-server-databasemail/

2

Example of Send Email in Tabular Format HTML Using SQL Server ...

Example of Send Email in Tabular Format HTML Using SQL Server Database Mail.pdf. Example of Send Email in Tabular Format HTML Using SQL Server ...

35KB Sizes 0 Downloads 153 Views

Recommend Documents

send pdf as html email
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. send pdf as html ...