資料庫郵件

2021-04-27 10:41:49 字數 1027 閱讀 9276

--直接發文字

exec msdb.dbo.sp_send_dbmail

@profile_name = 'zulin',

@recipients = '[email protected]',

@body='test',

@subject = '資料庫郵件測試'

--帶查詢結果

exec msdb.dbo.sp_send_dbmail

@profile_name = 'zulin',

@recipients = '[email protected]',

@query='select getdate()',

@subject = '資料庫郵件測試'

@attach query result as file =1;

--以html傳送

declare @tablehtml  nvarchar(max) ;

set @tablehtml =

n'' +

n'' +

n'work order id

product id' +

n'name

order qty

due date' +

n'expected revenue

' +cast ( ( select td = '1',       '',

td = '2', '',

td = '3', '',

td = '4', '',

td = '5', '',

td = '6'

for xml path('tr'), type

) as nvarchar(max) ) +

n'' ;

exec msdb.dbo.sp_send_dbmail @recipients='[email protected]',

@profile_name='zulin',

@subject = '資料庫郵件測試',

@body = @tablehtml,

@body_format = 'html' ;

資料庫郵件排除

資料庫遷移,郵件中出現問題。先增加賬戶後執行如下指令碼,關聯孤立賬戶 sp change users login action update one usernamepattern uat user loginname uat user 資料庫庫還原到新的伺服器後,傳送郵件報錯。檢視傳送錯誤日誌後確...

配置資料庫郵件

配置資料庫郵件,傳送郵件先要啟用資料庫郵件.可以從外圍應用配置器中啟用 見圖一 在sql server management studio中右擊資料庫郵件 配置資料庫郵件 見圖二 在 圖三 選擇通過執行以下任務來安裝資料庫郵件,在 圖四 指定乙個smtp賬號其中包括,賬號名 administrato...

配置資料庫郵件

配置資料庫郵件指令碼 1.開啟資料庫郵件 exec sp configure show advanced options 1 goreconfigure goexec sp configure database mail xps 1 goreconfigure go 2.建立郵件帳戶資訊 exec ...