Skip to content

Instantly share code, notes, and snippets.

@foontzoot
Created October 22, 2016 03:27
Show Gist options
  • Save foontzoot/384b8f35806d94e70e653bfe0e4c1901 to your computer and use it in GitHub Desktop.
Save foontzoot/384b8f35806d94e70e653bfe0e4c1901 to your computer and use it in GitHub Desktop.
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'DBMailAccount',
@email_address = 'test@test.com',
@replyto_address = 'noreply@test.com',
@display_name = 'SQL Server Agent Automated Mailer',
@mailserver_name = 'smtp.test.com',
@port = 587,
@username = 'user@test.com',
@password = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'DBMailProfile';
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'DBMailProfile',
@account_name = 'DBMailAccount',
@sequence_number = 1;
/* send test email */
EXEC msdb.dbo.sp_send_dbmail
@recipients = 'user@test.com',
@body= 'Test Email Body',
@subject = 'Test Email Subject',
@profile_name = 'DBMailProfile';
SELECT * FROM sysmail_allitems;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment