PL/SQL Procedure Send mail problem

Hi all I wrote a procedure to send email via plsql procedure, It was compiled successfully 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 )
Code
  1. CREATE OR REPLACE PROCEDURE send_test_message


  2. mailhost VARCHAR2(64) := 'mail.cmcltd.com';

  3. sender VARCHAR2(64) := 'akash.sharma@cmcltd.com';

  4. recipient VARCHAR2(64) := 'lalit.mohan@cmcltd.com';

  5. mail_conn UTL_SMTP.connection;


  6. DBMS_OUTPUT.put_line('Step:1');

  7. mail_conn := UTL_SMTP.open_connection(mailhost, 25);

  8. DBMS_OUTPUT.put_line('Step:2');

  9. UTL_SMTP.helo(mail_conn, mailhost);

  10. DBMS_OUTPUT.put_line('Step:3');

  11. UTL_SMTP.mail(mail_conn, sender);

  12. DBMS_OUTPUT.put_line('Step:4');

  13. UTL_SMTP.rcpt(mail_conn, recipient);

  14. DBMS_OUTPUT.put_line('Step:5');

  15. -- If we had the message in a single string, we could collapse

  16. -- open_data(), write_data(), and close_data() into a single call to data().

  17. UTL_SMTP.open_data(mail_conn);

  18. DBMS_OUTPUT.put_line('Step:6');

  19. UTL_SMTP.write_data(mail_conn, 'This is a test message.' || CHR(13));

  20. DBMS_OUTPUT.put_line('Step:7');

  21. UTL_SMTP.write_data(mail_conn, 'This is line 2.' || CHR(13));

  22. DBMS_OUTPUT.put_line('Step:8');

  23. UTL_SMTP.close_data(mail_conn);

  24. DBMS_OUTPUT.put_line('Step:9');

  25. DBMS_OUTPUT.put_line('Step:10');

  26. UTL_SMTP.quit(mail_conn);

  27. DBMS_OUTPUT.put_line('Step:11');



  28. DBMS_OUTPUT.put_line('not executed i m in exeption ');


  29. /
Copyright GeekInterview.com

SQL> exec send_test_message
Step:1
Step:2
Step:3
Step:4
not executed i m in exeption
please advise
thanks

Questions by lalit4untl   answers by lalit4untl

Showing Answers 1 - 3 of 3 Answers

KiranKW

  • May 2nd, 2007
 

Hi,

   I dont see any problem with your code ... try to capture the return code for each of the calls ... that will help to identify the exact problem

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions