Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: UTL_SMTP - How to set subject

Re: UTL_SMTP - How to set subject

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Fri, 2 Mar 2001 09:56:28 +0100
Message-ID: <97nn7u$p76$1@s1.read.news.oleane.net>

Here's a procedure from Tim K. Arnold (timkarnold_at_aol.com):

create or replace procedure send_mail (
mail_server IN VARCHAR2,
sender IN VARCHAR2,
recipient IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2)
IS

     c utl_smtp.connection;
     mesg VARCHAR2( 4000 );
     crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );

   BEGIN
     c := utl_smtp.open_connection(mail_server,25);
     utl_smtp.helo(c, mail_server);
     utl_smtp.mail(c, sender);
     utl_smtp.rcpt(c, recipient);
     mesg:= 'Date: ' || TO_CHAR(SYSDATE, 'dd Mon yy hh24:mi:ss');
     mesg:= mesg || crlf;
     mesg:= mesg || 'From: ' || sender || ' <' || sender || '>';
     mesg:= mesg || crlf;
     mesg:= mesg || 'To: ' || recipient || ' <' || recipient || '>';
     mesg:= mesg || crlf;
     mesg:= mesg || 'Subject: ' || subject;
     mesg:= mesg || crlf;
     mesg:= mesg || '' || crlf || message;
     utl_smtp.data(c, mesg);
     utl_smtp.quit(c);
   EXCEPTION
     WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
       utl_smtp.quit(c);
       raise_application_error(-20000,
         'Failed to send mail due to the following error: ' || sqlerrm);
   END;
/
--
Hope this helps
Michel


"Darryl" <djjr_at_ix.netcom.com> a écrit dans le message news: 3A9F4EA7.B82F36CF_at_ix.netcom.com...

> Anyone using this package to send email from a PL/SQL stored procedure?
> The one thing that is not obvious to me is how to set the subject of the
> mail message. Any one got this working. Using 8.1.7 on HP-UX.
>
> Thanks in advance
>
Received on Fri Mar 02 2001 - 02:56:28 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US