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: problem in procedure to send email via plsql procedure

Re: problem in procedure to send email via plsql procedure

From: EdStevens <quetico_man_at_yahoo.com>
Date: 23 Jan 2007 07:02:19 -0800
Message-ID: <1169564539.406235.307860@a75g2000cwd.googlegroups.com>

ganesh bora wrote:
> Hi all I wrote a procedure to send email via plsql procedure, It was
> compiled sucessfully but not working ....
>
> here is the code (actuly i added the dbms output like step1 ,step 2 to
> see in which step the control is going on )
>
> create or replace PROCEDURE send_test_message
> IS
> mailhost VARCHAR2(64) := 'gmail.com';
> sender VARCHAR2(64) := 'avc_at_gmail.com';
> recipient VARCHAR2(64) := 'djdjjdd_at_gmail.com';
> mail_conn utl_smtp.connection;
> BEGIN
> dbms_output.put_line('Step:1');
> mail_conn := utl_smtp.open_connection(mailhost, 25);
> dbms_output.put_line('Step:2');
> utl_smtp.helo(mail_conn, mailhost);
> dbms_output.put_line('Step:3');
> utl_smtp.mail(mail_conn, sender);
> dbms_output.put_line('Step:4');
> utl_smtp.rcpt(mail_conn, recipient);
> dbms_output.put_line('Step:5');
> -- If we had the message in a single string, we could collapse
> -- open_data(), write_data(), and close_data() into a single call to
> data().
> utl_smtp.open_data(mail_conn);
> dbms_output.put_line('Step:6');
> utl_smtp.write_data(mail_conn, 'This is a test message.' || chr(13));
> dbms_output.put_line('Step:7');
> utl_smtp.write_data(mail_conn, 'This is line 2.' || chr(13));
> dbms_output.put_line('Step:8');
> utl_smtp.close_data(mail_conn);
> dbms_output.put_line('Step:9');
> dbms_output.put_line('Step:10');
> utl_smtp.quit(mail_conn);
> dbms_output.put_line('Step:11');
> EXCEPTION
> WHEN OTHERS THEN
> dbms_output.put_line('not executed i m in exeption ');
> END;
> /
>
> SQL> exec send_test_message
> Step:1
> Step:2
> Step:3
> Step:4
> not executed i m in exeption
>
> plz give sum advise what i m doing wrong
>
> thanks

Since you got to step 4 and not to step 5, you obviously failed on the statement:

utl_smtp.rcpt(mail_conn, recipient);

Read up some more on utl_smtp.rcpt. Find out what kind of errors it can throw. Modify your EXCEPTION section to be a bit more informative of why you got there. Received on Tue Jan 23 2007 - 09:02:19 CST

Original text of this message

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