sql server提供了通過exchange或outlook收發(fā)郵件的擴(kuò)展存儲(chǔ)過程,下面將這幾個(gè)過程簡單的介紹一下。
一、啟動(dòng)sql mail
    xp_startmail @user,@password
        
            @user和@password都是可選的
    也可打開enterprise manager中的support services,在sql mail上單擊右鍵打開右鍵菜單,然后按start來啟動(dòng)
二、停止sql mail
    xp_stopmail
    也可用上述方法中的菜單里的stop來停止
三、發(fā)送郵件
    xp_sendmail {[@recipients =] 'recipients [;...n]'} 
        [,[@message =] 'message'] 
        [,[@query =] 'query'] 
        [,[@attachments =] attachments] 
        [,[@copy_recipients =] 'copy_recipients [;...n]'
        [,[@blind_copy_recipients =] 'blind_copy_recipients [;...n]'
        [,[@subject =] 'subject']
        [,[@type =] 'type'] 
        [,[@attach_results =] 'attach_value']
        [,[@no_output =] 'output_value'] 
        [,[@no_header =] 'header_value'] 
        [,[@width =] width] 
        [,[@separator =] 'separator'] 
        [,[@echo_error =] 'echo_value'] 
        [,[@set_user =] 'user'] 
        [,[@dbuse =] 'database']
    其中@recipients是必需的
    參數(shù)說明:
參數(shù) 說明 
@recipients 收件人,中間用逗號(hào)分開 
@message 要發(fā)送的信息 
@query 確定執(zhí)行并依附郵件的有效查詢,除觸發(fā)器中的插入表及刪除表外,此查詢能引用任何對(duì)象 
@attachments 附件 
@copy_recipients 抄送 
@blind_copy_recipients 密送 
@subject 標(biāo)題 
@attach_results 指定查詢結(jié)果做為附件發(fā)送 
@no_header 不發(fā)送查詢結(jié)果的列名 
@set_user 查詢聯(lián)接的用戶名,默認(rèn)為guset 
@dbuse 查詢所用的數(shù)據(jù)庫,默認(rèn)為缺省數(shù)據(jù)庫 
四、閱讀郵件收件箱中的郵件
    xp_readmail [[@msg_id =] 'message_number'] [, [@type =] 'type' [output]] 
        [,[@peek =] 'peek']
        [,[@suppress_attach =] 'suppress_attach']
        [,[@originator =] 'sender' output]
        [,[@subject =] 'subject' output]
        [,[@message =] 'message' output]
        [,[@recipients =] 'recipients [;...n]' output]
        [,[@cc_list =] 'copy_recipients [;...n]' output]
        [,[@bcc_list =] 'blind_copy_recipients [;...n]' output]
        [,[@date_received =] 'date' output]
        [,[@unread =] 'unread_value' output]
        [,[@attachments =] 'attachments [;...n]' output])
        [,[@skip_bytes =] bytes_to_skip output]
        [,[@msg_length =] length_in_bytes output]
        [,[@originator_address =] 'sender_address' output]]
    參數(shù)說明:
參數(shù) 說明 
@originator 發(fā)件人 
@subject 主題 
@message 信息 
@recipients 收件人 
@skip_tytes 讀取郵件信息時(shí)跳過的字節(jié)數(shù),用于順序獲取郵件信息段。 
@msg_length 確定所有信息的長度,通常與@skip_bytes一起處理長信息 
五、順序處理下一個(gè)郵件
    xp_findnextmsg [[@msg_id =] 'message_number' [output]] 
        [,[@type =] type] 
        [,[@unread_only =] 'unread_value'])
六、刪除郵件
    xp_deletemail {'message_number'}
    如果不指定郵件編號(hào)則刪除收件箱中的所有郵件
七、自動(dòng)處理郵件
    sp_processmail [[@subject =] 'subject']
        [,[@filetype =] 'filetype']
        [,[@separator =] 'separator']
        [,[@set_user =] 'user']
        [,[@dbuse =] 'dbname'] 
本文章來自于http://www.aspcn.com   asp中華網(wǎng)如要轉(zhuǎn)載請(qǐng)務(wù)必注明出處,謝謝