-- =================================================
-- 配置
DECLARE
@account_name sysname,
@profile_name sysname;
SELECT
@account_name = N'[email protected]', -- 資料庫郵件帳号
@profile_name = N'qq'; -- 資料庫郵件配置檔案名
-- 資料庫郵件帳号
EXEC msdb.dbo.sysmail_add_account_sp
@account_name = @account_name,
@email_address = N'[email protected]', -- Email 位址
@display_name = N'qq test', -- 回複位址
@mailserver_name = N'smtp.gmail.com', -- Gmail smtp 伺服器位址
@port = 25, -- 端口号(對于Gmail, 如果25 不通則改用456)
@username = N'[email protected]', -- Gmail 郵件位址
@password = N'password', -- Gmail 郵件帳号密碼
@use_default_credentials = 0,
@enable_ssl = 1; -- 啟用SSL 通訊加密
-- 資料庫郵件配置檔案
EXEC msdb.dbo.sysmail_add_profile_sp
@profile_name = @profile_name;
-- 把資料庫郵件帳号添加到郵件配置檔案中
EXEC msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = @profile_name,
@sequence_number = 1;
-- 授予任意使用者使用資料庫郵件配置檔案的權限
EXEC msdb.dbo.sysmail_add_principalprofile_sp
@principal_name = N'guest',
@is_default = 0;
本文轉自 Fanr_Zh 部落格園部落格,原文連結:http://www.cnblogs.com/Amaranthus/archive/2011/06/16/2082409.html,如需轉載請自行聯系原作者