您的位置:首页 > 大数据 > 人工智能

how to setup DatabaseMail(with MS Exchange Server)

2007-08-06 16:08 555 查看
--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 = 'FISADM@IACP.IAC',
@replyto_address = 'FISADM@IACP.IAC',
@display_name = 'FISADM@IACP.IAC',
@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 = 'cdq@gmail.com;',
@subject = 'MyDBMAIL',
@body = 'Test Email'

select sent_status,* from msdb.dbo.sysmail_allitems 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息