{"id":156,"date":"2011-07-18T11:35:34","date_gmt":"2011-07-18T16:35:34","guid":{"rendered":"\/\/www.beauchamp.me\/techno\/?p=156"},"modified":"2011-07-18T11:35:34","modified_gmt":"2011-07-18T16:35:34","slug":"permission-problem-to-run-msdb-dbo-sp_send_dbmail","status":"publish","type":"post","link":"https:\/\/www.beauchamp.me\/techno\/blog\/2011\/07\/18\/permission-problem-to-run-msdb-dbo-sp_send_dbmail\/","title":{"rendered":"Permission problem to run msdb.dbo.sp_send_dbmail"},"content":{"rendered":"<p>I needed to be able to send emails from a stored procedure using something like<\/p>\n<pre class=\"brush:sql\">EXECUTE msdb.dbo.sp_send_dbmail @recipients='address@domainname.com',\r\n@subject = 'Test email',\r\n@body = 'Test email body'\r\n<\/pre>\n<p>The solution was to add the user I was using to run the above query to the msdb database and to assign the role DatabaseMailUserRole to the user:<\/p>\n<pre class=\"brush:sql\">EXEC msdb.dbo.sp_addrolemember @rolename = 'DatabaseMailUserRole'\r\n    ,@membername = 'myUserName';<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I needed to be able to send emails from a stored procedure using something like EXECUTE msdb.dbo.sp_send_dbmail @recipients=&#8217;address@domainname.com&#8217;, @subject = &#8216;Test email&#8217;, @body = &#8216;Test email body&#8217; The solution was to add the user I was using to run the above query to the msdb database and to assign the role DatabaseMailUserRole to the user: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-sql-server-2005"],"_links":{"self":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":3,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/posts\/156\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beauchamp.me\/techno\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}