SQL Server Allow users to access sp_send_dbmail to send email

After setting up an email account / profile in SQL server (https://robbamforth.wordpress.com/2008/10/21/sql-server-2005-database-mail/) you must give each user account permission to access the sp_send_dbmail procedure.

This is done in the following way:

When setting up a new user, select the User Mapping option from the left hand side of the screen.
Scroll down to the MSDB database and tick the box next to it.
Under Database role Membership for:MSDB select DatabaseMailUserRole.
Complete the new user set up as usual.

This user now has permission to access procedures using the sp_send_dbmail command, such as sending database mail:

EXEC msdb.dbo.sp_send_dbmail

    @profile_name = EMAIL_PROFILE’,

    @recipients = test@test.som’,

    @subject = ‘This is a test email’,

    @body = ‘Sample Message’,    

    @body_format = ‘HTML’;

 

 

Advertisements

One thought on “SQL Server Allow users to access sp_send_dbmail to send email

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s