Tuesday, July 16, 2013

Mail From Sqlserver Database Error solution

Minimal permissions to send Database mail

If you encounter the following error when trying to send a database mail

EXECUTE permission denied on object 'sp_send_dbmail', database 'msdb', schema 'dbo'

you have a problem with SQL Server privileges

The easies way to fix this is to make your user a member of the *DatabaseMailUserRole* database role in the msdb database. You can do that in SQL Server Management Studio, or using the following SQL

EXEC msdb.dbo.sp_addrolemember @rolename='DatabaseMailUserRole' ,@membername='<user or role name>'

Note that the DatabaseMailUserRole doesn't exist in the SQL Server Security | Server Role list, just in the msdb database roles

Minimal permissions to send Database mail

If you encounter the following error when trying to send a database mail

EXECUTE permission denied on object 'sp_send_dbmail', database 'msdb', schema 'dbo'

you have a problem with SQL Server privileges
The easies way to fix this is to make your user a member of the  *DatabaseMailUserRole* database role in the msdb database. You can do that in SQL Server Management Studio, or using the following SQL

EXEC msdb.dbo.sp_addrolemember @rolename='DatabaseMailUserRole' ,@membername='<user or role name>'


Note that the DatabaseMailUserRole doesn't exist in the SQL Server Security | Server Role list, just in the msdb database roles