Blog Pages

reate a Database Mail account and profile

-- Create a Database Mail account
EXECUTE msdb.dbo.sysmail_add_account_sp
    @account_name = 'account_name',
    @description = '',
    @email_address = 'mail@mail.com',
    @replyto_address = 'mail@mail.com',
    @display_name = 'Display_Name',
    @mailserver_name = '10.200.10.10';

-- Create a Database Mail profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
    @profile_name = 'MyProfile',
    @description = 'Profile for bla bla bla';

-- Add the account to the profile
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
    @profile_name = 'MyProfile',
    @account_name = 'account_name',
    @sequence_number ;

-- Grant access to the profile to the DBMailUsers role
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
    @profile_name = 'MyProfile',
    @principal_name = 'guest',
    @is_default = 0-- or 1 


No comments:

Post a Comment