Fosdccf.blog.chinaunix.net
sdccf
全部博文(19283)
Linux酷软(214)
tmp(0)
PostgreSQL(93)
Solaris(383)
AIX(173)
SCOUNIX(575)
DB2(1005)
Shell(386)
C/C++(1187)
MySQL(1750)
Sybase(465)
Oracle(3695)
Informix(548)
HP-UX(0)
IBM AIX(2)
Sun Solaris(0)
BSD(1)
Linux(8597)
SCO UNIX(23)
2011年(1)
2009年(125)
2008年(19094)
2007年(63)
clifford
linky521
曾德标
fengzhan
leon_yu
mcuflowe
yt200902
guanyuji
GY123456
snow888
carlos94
丸喵喵
sean229
cxunix
可怜的猪
cqxc413
xzzgege
wb123456
分类: Oracle
2008-04-30 16:30:00
出自:http://realji.itpub.net/post/18984/126758找了半天,终于在某个大哥的blog上找到了。CREATE OR REPLACE PROCEDURE send_mail(p_recipient IN VARCHAR2,p_message IN VARCHAR2,p_subject IN VARCHAR2 DEFAULT 'Oracle Perf Report '|| TO_CHAR (SYSDATE, 'yyyy-mm-dd hh24:mi:ss'),p_sender IN VARCHAR2 DEFAULT [url=mailto:%%27]'')IS v_mailhost VARCHAR2 (30) := '202.108.5.83'; --SMTP服务器地址 mail_conn UTL_SMTP.connection; msg VARCHAR2 (4000); p_user VARCHAR2 (30) := [url=mailto:%%27]''; --登录SMTP服务器的用户名 p_pass VARCHAR2 (30) := 'password' ; --登录SMTP服务器的密码 BEGIN /* 创建要发送的邮件内容 注意报头信息和邮件正文之间要空一行 */ msg := 'Date:' || TO_CHAR (SYSDATE, 'dd mon yy hh24:mi:ss') || UTL_TCP.crlf || 'From: ' || p_sender || '<' || p_sender || '>' || UTL_TCP.crlf || 'To: ' || p_recipient || '<' || p_recipient || '>' || UTL_TCP.crlf || 'Subject: ' || p_subject || UTL_TCP.crlf || UTL_TCP.crlf || p_message; -- dbms_output.put_line(msg); mail_conn := UTL_SMTP.open_connection (v_mailhost, 25); UTL_SMTP.helo (mail_conn, v_mailhost); /* smtp服务器登录校验 */ UTL_SMTP.command (mail_conn, 'AUTH LOGIN'); UTL_SMTP.command (mail_conn, UTL_RAW.cast_to_varchar2 (UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw (p_user) ) ) ); UTL_SMTP.command (mail_conn, UTL_RAW.cast_to_varchar2 (UTL_ENCODE.base64_encode (UTL_RAW.cast_to_raw (p_pass) ) ) ); UTL_SMTP.mail (mail_conn, p_sender); UTL_SMTP.rcpt (mail_conn, p_recipient); /* 发送数据 */ UTL_SMTP.DATA (mail_conn, msg); UTL_SMTP.quit (mail_conn); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_stack); DBMS_OUTPUT.put_line (DBMS_UTILITY.format_call_stack); NULL; END send_mail;
上一篇:ORACLE函数大全
下一篇:在Oracle中实现定时操作
登录 注册