Configure sql mail Basic steps
//Run followings in sql query window
use master
go
sp_configure 'show advanced options',1
go
reconfigure with override
go
sp_configure 'Database Mail XPs',1
--go
--sp_configure 'SQL Mail XPs',0
go
reconfigure
go
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'MyMailAccount',
@description = 'Mail account for Database Mail',
@email_address = 'Sanjeewa@mail.com',
@display_name = 'MyAccount',
@username='Sanjeewa@alliontechnologies.com',
@password='tExt123',
@mailserver_name = 'mail.yourmail.com'
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'MyMailProfile',
@description = 'Profile used for database mail'
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'MyMailProfile',
@account_name = 'MyMailAccount',
@sequence_number = 1
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'MyMailProfile',
@principal_name = 'public',
@is_default = 1 ;
//Send a test mail
declare @body1 varchar(100)
set @body1 = 'Server :'+@@servername+ ' My First Database Email xxxyyii'
EXEC msdb.dbo.sp_send_dbmail @recipients='Sanjeewa@Mail.com',
@subject = 'My Mail Test',
@body = @body1,
@body_format = 'HTML' ;
Tuesday, August 26, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment