------------- Enable advanced options --------------
use master
go
sp_configure 'show advanced options',1
go
reconfigure with override
go
sp_configure 'Database Mail XPs',1
go
reconfigure
go
----------Configure Mail Account--------------------------
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'SQLAlerts',
@description = 'SQLAlerts',
@email_address = 'sqlserver_dbateam@tunein.in',
@display_name = 'SQLAlerts',
@mailserver_name = 'mailserver.tunein.in'
-----------Creating Profile-----------------------------
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'SQLAlerts',
@description = 'Profile used for sending SQLAlerts'
----------Add the Database Mail account we created in step 2, to the Database Mail profile created in Step3----
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'SQLAlerts',
@account_name = 'SQLAlerts',
@sequence_number = 1
------- Send Test Mails using the profile created------------------
declare @bodymsg varchar(100)
set @bodymsg = 'Server :'+@@servername+ ' First Database Email '
EXEC msdb.dbo.sp_send_dbmail @recipients='sakthi@tunein.in',
@subject = 'Test Mail',
@body = @bodymsg,
@body_format = 'HTML' ;
No comments:
Post a Comment
Please do not spam!