oracle内发送email

  • Post author:
  • Post category:其他


create or replace procedure ProcSendEmail(txt varchar2)

IS

–sender’s email address

SendorAddress Varchar2(30) :=

‘xxx@xxx.com’

;

–receiver ‘s email address

ReceiverAddress varchar2(30) :=

‘xxx@xxx.com’

;

–mail server’s name or ip address

EmailServer varchar2(30) := ‘10.10.1.168’;

Port number := 25;

conn UTL_SMTP.CONNECTION;

crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );

contentmsg VARCHAR2( 60 ) := ‘hello’;

mesg VARCHAR2( 4000 );

mesg_body varchar2(4000);

BEGIN

conn:= utl_smtp.open_connection( EmailServer, Port );

utl_smtp.helo( conn, EmailServer );

utl_smtp.mail( conn, SendorAddress);

utl_smtp.rcpt( conn, ReceiverAddress );

mesg:=

‘Content-Type: text/plain; Charset=GB2312’ || crlf ||

‘Date:’ || TO_CHAR( SYSDATE, ‘dd Mon yy hh24:mi:ss’ ) || crlf ||

‘From:’ || SendorAddress || crlf ||

‘Subject: Sending Mail From Database’ || crlf ||

‘To: ‘|| ReceiverAddress || crlf ||

‘Content-Type: text/plain; Charset=GB2312’ || crlf ||

” || crlf || txt || crlf ;

utl_smtp.data( conn, mesg );

utl_smtp.quit( conn );

END;



版权声明:本文为puserzhou原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。