zoukankan      html  css  js  c++  java
  • How to configure SQL 2005 Database Mail

    --配置邮件步骤 
    --
    -启用 SQL Server 2005 邮件功能。
    use master
    go
    exec sp_configure 'show advanced options',1
    go
    reconfigure
    go
    exec sp_configure 'Database mail XPs',1
    go
    reconfigure
    go

    ---在 SQL Server 2005 中添加邮件帐户(account)
    exec msdb..sysmail_add_account_sp        
    @account_name= 'SqlServerName'                 -- 邮件帐户名称(SQL Server 使用)      
    ,@email_address= 'test@139.com'  -- 发件人邮件地址       
    ,@display_name= lvxuefen                      -- 发件人姓名       
    ,@replyto_address= null       
    ,@description= null       
    ,@mailserver_name= '192.168.0.1'           -- 邮件服务器地址       
    ,@mailserver_type= 'SMTP'                    -- 邮件协议(SQL 2005 只支持 SMTP)       
    ,@port= 25                        -- 邮件服务器端口       
    ,@username= 'lvxuefen@163.com'  -- 用户名       
    ,@password = 'abc123'               -- 密码       
    ,@use_default_credentials = 0       
    ,@enable_ssl= 0       
    ,@account_id  = null

    -- 在 SQL Server 2005 中添加 profile 
    exec msdb..sysmail_add_profile_sp @profile_name = 'dba_profile'      -- profile 名称
    ,@description  = 'dba mail profile' -- profile 描述                                  
    ,@profile_id   = null

    --在 SQL Server 2005 中映射 account 和 profile 
    exec msdb..sysmail_add_profileaccount_sp  @profile_name = 'dba_profile' -- profile 名称                                         
     ,@account_name    = 'SqlServerName'     -- account 名称                                          
    ,@sequence_number = 1             -- account 在 profile 中顺序 


    --利用 SQL Server 2005 Database Mail 功能发送邮件。 
    exec msdb..sp_send_dbmail @profile_name =  'dba_profile'               -- profile 名称                          
    ,@recipients   =  'test@139.com'          -- 收件人邮箱                          
    ,@subject      =  'SQL Server 2005 Mail Test' -- 邮件标题                          
    ,@body         =  'Test DB Mail!'               -- 邮件内容                          
    ,@body_format  =  'TEXT'                      -- 邮件格式 




    --查看邮件发送情况: 
    use msdb
    go
    select * from sysmail_allitems
    select * from sysmail_mailitems
    select * from sysmail_event_log
  • 相关阅读:
    将十六进制数组转换为字符串
    TEA(Tiny Encryption Algorithm)
    Install Atom editor in ubuntu 14.04
    Install Sublime Text 3
    测试键盘的控制字符对应的ASCII码值
    Linux 文件访问权限
    Linux 关机命令
    数据创建命令
    关键词
    MySQL命令总汇
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2191783.html
Copyright © 2011-2022 走看看