how to setup DatabaseMail(with MS Exchange Server)

--SQL Server 2005 Surface Area Configuration
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO

-- Creates a new Database Mail account
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'FISADM',
@description = 'FISADM',
@email_address = '[email protected]',
@replyto_address = '[email protected]',
@display_name = '[email protected]',
@mailserver_name = 'iacp-mail3.iacp.iac',
@port = 25,
@username ='iacp/FISADM',
@password ='XXXX',
@enable_ssl = 0

-- Create a Database Mail profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'FISprofile',
@description = 'Profile used for FIS.'

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

-- Grant access to the profile to all users in the msdb database
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'FISprofile',
@principal_name = 'public',
@is_default = 1 ;  -- later, you can update it through T-SQL: 'update sysmail_principalprofile set ...'

--After this configuration you can send mail by calling the system store procedure dbo.sp_send_dbmail
EXECUTE msdb.dbo.sp_send_dbmail
--@profile_name = 'FISprofile',
@recipients = '[email protected];',
@subject = 'MyDBMAIL',
@body = 'Test Email'

select sent_status,* from msdb.dbo.sysmail_allitems 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章