1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
USE Master
GO
sp_configure 'show advanced options', 1
GO
reconfigure with override
GO
sp_configure 'Database Mail XPs', 1
GO
reconfigure
GO
sp_configure 'show advanced options', 0
GO
-- Create new profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'test',
@description = 'Profile to send the notification emails'
-- Set the New Profile as the Default
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'test',
@principal_name = 'public',
@is_default = 1 ;
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'test',
@description = 'my email description',
@email_address = 'monadresse@maboite.com',
@display_name = 'My email display name',
@mailserver_name = 'smtp.wanadoo.fr',
@port = 25,
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'test',
@account_name = 'test',
@sequence_number = 1
GO
EXECUTE msdb.dbo.sp_send_dbmail
@recipients='monmail@maboite.com',
@subject = 'Test e-mail sent from database mail',
@body = 'This is a test message sent from the newly created database mail account',
GO |
Partager