How to solve EXECUTE Permission denied on object 'sp_send_dbmail'

Hi guys,
Welcome back !

Today a light five minute post to talk about this error:

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


..or in italian language:

Autorizzazione execute negata per l'oggetto 'sp_send_dbmail' del database 'msdb' con schema 'dbo'


The sp_send_dbmail


You know that this stored procedure is used to send a mail through SQL server.
You know also that this stored procedure is contained into the MSDB system Databases.
But if you get the error above? What can you do?

How to solve the execute permission denied on sp_send_dbmail

You should consider that:
  • Your user must be in the MSDB database. 
  • Your user must be also member of the DatabaseMailUserRole
You can solve the problem in this way:

1) In the Object Explorer of the SQL Server management Studio, locate the Security / Account menu. Locate your user and do a double click on it.



2) In the opened window you should check:

  • In the upper grid, check the row where Database is msdb e then specify your user.
  • In the lower grid check, check the DatabaseMailUserRole Role.





Note that you can also do this configuration throu this command: 

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


That's all for today.

Stay tuned for the next posts!

See you soon,
Luca


If you find an advertisement that genuinely interests you, simply click it from on my blog. 
You will help me keep writing more and more interesting content. ~Luke


Luca Biondi @ SQLServerPerformance blog 2020!    

Comments

I Post più popolari

SQL Server, execution plan and the lazy spool (clearly explained)

SQL Server, datetime vs. datetime2