I am getting this error:
Msg 229, Level 14, State 5, Procedure sp_send_dbmail, Line 1
The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'.
The relevant part of the code:
/****** Object: StoredProcedure [dbo].[dbo.STATUSCHANGE_EMAILALERT] ******/
EXEC msdb.dbo.sp_send_dbmail
@recipients = '[email protected]', -- Group Email
@subject = 'Employee Status Update',
@profile_name ='[email protected]', -- Setup the profile name group
@body = @body,
@body_format = 'HTML';
Could not find stored procedure 'sp_send_dbmail' The sp_send_dbmail stored procedure is installed in the msdb database. You must either run sp_send_dbmail from the msdb database, or specify a three-part name for the stored procedure. Use Database Mail Configuration Wizard to enable and configure database mail.
The msdb database is a system database that is used by several SQL Server components such as the SQL Server Agent service. In addition to SQL Server Agent configuration and task information, replication, log shipping, and maintenance plan data are stored in the msdb database.
To grant permissions to a user, database role, or application role, select Search. In Select Users or Roles, select Object Types to add or clear the users and roles you want. Select Browse to display the list of users or roles. Select the users or roles to whom permissions should be granted.
Found nice and easy fix that worked for me here:
If your SQL applications can’t send email using database mail (I assume you already have DBMail Account and Profile setup), there are two things to set:
To send Database mail, users must be a user in the msdb database and a member of the DatabaseMailUserRole
database role in the msdb database. To add msdb users or groups to this role use SQL Server Management Studio or execute the following statement for the user or role that needs to send Database Mail:
EXEC msdb.dbo.sp_addrolemember @rolename = 'DatabaseMailUserRole'
,@membername = '<user or role name>';
GO
Grant execute permission on sp_send_dbmail
to the user executing the stored procedure, or add them to the role msdb.DatabaseMailUser
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With