使用SQL Mail收發和自動處理郵件

2021-04-23 14:37:40 字數 2725 閱讀 9214

sql server提供了通過exchange或outlook收發郵件的擴充套件儲存過程,下面將這幾個過程簡單的介紹一下。

一、啟動sql mail

xp_startmail @user,@password

@user和@password都是可選的

也可開啟enterprise manager中的support services,在sql mail上單擊右鍵開啟右鍵選單,然後按start來啟動

二、停止sql mail

xp_stopmail

也可用上述方法中的選單裡的stop來停止

三、傳送郵件

xp_sendmail

[,[@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是必需的

引數說明:

引數 說明

@recipients 收件人,中間用逗號分開

@message 要傳送的資訊

@query 確定執行並依附郵件的有效查詢,除觸發器中的插入表及刪除表外,此查詢能引用任何物件

@attachments 附件

@copy_recipients 抄送

@blind_copy_recipients 密送

@subject 標題

@attach_results 指定查詢結果做為附件傳送

@no_header 不傳送查詢結果的列名

@set_user 查詢聯接的使用者名稱,預設為guset

@dbuse 查詢所用的資料庫,預設為預設資料庫

四、閱讀郵件收件箱中的郵件

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]]

引數說明:

引數 說明

@originator 發件人

@subject 主題

@message 資訊

@recipients 收件人

@skip_tytes 讀取郵件資訊時跳過的位元組數,用於順序獲取郵件資訊段。

@msg_length 確定所有資訊的長度,通常與@skip_bytes一起處理長資訊

五、順序處理下乙個郵件

xp_findnextmsg [[@msg_id =] 'message_number' [output]]

[,[@type =] type]

[,[@unread_only =] 'unread_value'])

六、刪除郵件

xp_deletemail

如果不指定郵件編號則刪除收件箱中的所有郵件

七、自動處理郵件

sp_processmail [[@subject =] 'subject']

[,[@filetype =] 'filetype']

[,[@separator =] 'separator']

[,[@set_user =] 'user']

[,[@dbuse =] 'dbname']

Vim中自動在程式起始處新增版權和作者資訊

在編寫程式的時候,經常需要在程式開始寫上程式的簡要介紹和作者資訊,如下 這種資訊,除了檔名和修改時間可能經常發生變化外,其他基本不變,可以在程式開始自動加入,方法就是在家目錄下的.vimrc中寫入 儲存之後,vi test.sh,在norm 模式下按下f4即可,效果如下 假如下一時刻,我們將檔名稱改...

使用 bat 自動設定IP位址和自動獲取IP位址

自動設定ip位址.bat echo off echo 手動設定ip位址.netsh inte ce ip set addr 本地連線 static 192.168.1.8 255.255.255.0 192.168.1.1 1 echo 手動設定dns位址.netsh inte ce ip set ...

UILabel設定自動使用高和換行

初始化label uilabel label uilabel alloc initwithframe cgrectmake 0,0,0,0 設定自動行數與字元換行 label setnumberoflines 0 label.linebreakmode uilinebreakmodewordwrap...