使用SQLMail收发和自动处理邮件
日期:2006-04-20 荐:
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 {[@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是必需的 参数说明: 参数 说明 @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 {"message_number"} 如果不指定邮件编号则删除收件箱中的所有邮件 七、自动处理邮件 sp_processmail [[@subject =] "subject"] [,[@filetype =] "filetype"] [,[@separator =] "separator"] [,[@set_user =] "user"] [,[@dbuse =] "dbname"]
标签: