Skip to content

Instantly share code, notes, and snippets.

@davops
Created June 2, 2016 15:16
Show Gist options
  • Save davops/fcca671e46fa3160dce8ea5f4e8dfb49 to your computer and use it in GitHub Desktop.
Save davops/fcca671e46fa3160dce8ea5f4e8dfb49 to your computer and use it in GitHub Desktop.
Query to search for an existing email profile in SQL & send an email using it
--Find a prexisting email profile to be inserted into the "@profile_name" variable below
EXEC msdb.dbo.sysmail_help_profile_sp;
--Define the text you will email
DECLARE @body NVARCHAR(MAX)
SET @body = 'Whatever you want to send yourself'
--Send the email using the email profile found
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Administrator Profile',
@recipients = 'administrator@youremail.com',
@body = @body,
@subject = 'Test Email';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment