Thursday, March 14, 2013

msdb.dbo.sp_send_dbmail

to get this to work...

  1. In SSMS at: Databases > System Databases > msdb ...you must add the same user that you will use to connect to your database to call the SQL
  2. In SSMS at: Management > Database Mail ...right click and pick "Configure Database Mail" to prep the SMTP and the profile to be used as seen here:
    set @Foo = ERROR_MESSAGE();
    SET @Bar = 'Something went wrong.'
    EXEC msdb.dbo.sp_send_dbmail
       @profile_name='CustomerService'
       ,@recipients='tomjaeschke@tomjaeschke.com'
       ,@subject = @Bar
       ,@body = @EFoo
       ,@body_format = 'HTML'

No comments:

Post a Comment