Wrox Programmer Forums
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 31st, 2003, 03:45 AM
Authorized User
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default PL/SQL

   I am trying to develop a system where it has some data parsed from XML document and stored in Oracle. The system should process the data and send e-mail to the users. I was wondering, since I am new to PL/SQL, how to use stored procedures written in PL/SQL to send e-mails. I would truly appreciate any help or suggestions for this problem.

Thank you
Old March 3rd, 2005, 10:54 AM
Registered User
Join Date: Feb 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to SureshHyd

check the following code. I have copied it from some other source.

  msg_from varchar2 := 'oracle',
  msg_to varchar2,
  msg_subject varchar2 := 'E-Mail message from your database',
  msg_text varchar2 := '' )
  c utl_tcp.connection;
  rc integer;
  c := utl_tcp.open_connection('', 25); -- open the SMTP port 25 on local machine
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  rc := utl_tcp.write_line(c, 'HELO localhost');
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
  rc := utl_tcp.write_line(c, '');
  rc := utl_tcp.write_line(c, msg_text);
  rc := utl_tcp.write_line(c, '.'); -- End of message body
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  rc := utl_tcp.write_line(c, 'QUIT');
  dbms_output.put_line(utl_tcp.get_line(c, TRUE));
  utl_tcp.close_connection(c); -- Close the connection
  when others then
           -20000, 'Unable to send e-mail message from pl/sql because
            of: '|| sqlerrm);
show errors

-- Examples:
set serveroutput on

exec send_mail(msg_to =>'orafaq@orafaq.org');

exec send_mail(msg_to =>'orafaq@orafaq.org', -
           msg_text=>'Look Ma, I can send mail from plsql' - );

Similar Threads
Thread Thread Starter Forum Replies Last Post
PL/SQL Somesh ASP.NET 1.0 and 1.1 Basics 7 December 15th, 2006 05:49 PM
PL/SQL Cursor help Wikked Oracle 1 March 12th, 2005 01:19 AM
PL/SQL i need help loveboy23 Oracle 3 January 6th, 2005 01:14 AM
PL/SQL help carly_1 Oracle 1 October 19th, 2003 08:14 PM
PL/SQL help Blue Oracle 0 August 12th, 2003 02:54 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.