July 10, 2009

Resolving the error - EXECUTE permission denied on object 'sp_send_dbmail', database 'msdb', schema 'dbo'

Recently, a viewer mailed me asking about an error in Database Mail. The error was EXECUTE permission denied on object sp_send_dbmail, database 'msdb', schema 'dbo'.

The error means that the user who is trying to send Database Mail does not have the required permissions to execute sp_send_dbmail. To be able to send mail using Database mail, a user has to be a member of the ‘DatabaseMailUserRole’ role in the msdb database. Here’s how to add the user to this role

USE msdb
EXEC msdb.dbo.sp_addrolemember @rolename = 'DatabaseMailUserRole',
@membername = 'SomeDomain\SomeDomainUser';
After successful execution of this statement, the error should be fixed.

About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

No comments: