![](/img/trans.png)
[英]Sending query results via email via email attachment every first day of every month on SQL Server 2012
[英]Sending an email via SQL Server causes error
我正在嘗試通過SQL Server Management Studio發送電子郵件,但返回錯誤。
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Adventure Works Administrator',
@recipients = 'example@example.com',
@body = 'The stored procedure finished successfully.',
@subject = 'Automated Success Message'
錯誤是:
對對象'sp_send_dbmail',數據庫'msdb',模式'dbo'的EXECUTE權限被拒絕。
我已經上網沖浪以解決此問題,但沒有解決。 需要你的幫助。 謝謝
如注釋中所建議,也許您的用戶對要定位的SQL實例沒有正確的權限:
grant execute on dbo.sp_send_dbmail to <usernamehere>;
請參閱有關此問題的疑難解答文章 :
EXEC msdb.dbo.sp_addrolemember @rolename = 'DatabaseMailUserRole'
,@membername = '<user or role name>';
GO
另外,您可能尚未配置此功能,請參閱文檔 :
在使用之前,必須使用“數據庫郵件配置向導”或sp_configure啟用數據庫郵件。
而這一配置:
USE master
Go
EXEC sp_configure 'show advanced options', 1
Go
RECONFIGURE
Go
EXEC sp_configure 'Database Mail XPs', 1
Go
RECONFIGURE
Go
EXEC sp_configure 'show advanced options', 0
Go
RECONFIGURE
Go
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.