• Brilliant article.

    Only one thing which is a bit of a shame - this only works if the SP is execute as owner, not if it's execute as caller.

    As a result, if you look in msdb.dbo.sysmail_allitems, all items sent with this method say they were sent by sa. Also it's allowed to send using private profiles to which nobody has been granted access.

    If you send the mail by adding the user to the msdb role instead, then msdb.dbo.sysmail_allitems details the correct sender.

    DatabaseMail is great, but the permissions are a real struggle. In addition to the sp_send_dbmail permission problem, it's hard to get the permissions sorted out for private profiles. All the documentation says that you can grant permissions on private profiles to database roles in msdb, but in actual fact it won't let you do this.

    Rachel.