2011年4月7日 星期四

轉貼...Database Mail 送出html tabular 郵件

之前用FOR XML PATH組出一個COLUMN多筆資料變成一筆...

這次再次見識他的強大...

Send email in a tabular format using SQL Server database mail


Database Mail設定
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO

-- Create a Database Mail account
  EXECUTE msdb.dbo.sysmail_add_account_sp
 @account_name = 'Bev',
 @description = 'Mail account for test e-mail.',
 @email_address = 'test@test.com',
 @replyto_address = null,
 @display_name = 'Beverly',
 @mailserver_name = 'test.com' ;
 
  -- Create a Database Mail profile
 EXECUTE msdb.dbo.sysmail_add_profile_sp
 @profile_name = 'Hinet',
 @description = 'Profile used for test mail.' ;
 
  -- Add the account to the profile (一個profile可有多個account)
 EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
 @profile_name = 'Hinet',
 @account_name = 'Bev',
 @sequence_number =1 ;
 
 
  -- Grant access to the profile to the DBMailUsers role
 EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
 @principal_name = 'public',
 @profile_name = 'Hinet',
 @is_default = 1 ;



 

沒有留言:

張貼留言

離線安裝SSMS 22 launched extracted application exiting with result code 0x138b

SSMS 22 安裝器下載頁面 https://learn.microsoft.com/zh-tw/ssms/install/install https://aka.ms/ssms/22/release/vs_SSMS.exe 將安裝檔下載到本機,檔案好大2.5G  https:...