Home » SQL & PL/SQL » SQL & PL/SQL » how to send a mail using PL/SQL procedure
how to send a mail using PL/SQL procedure [message #233765] Fri, 27 April 2007 07:18 Go to next message
rajareddy_24
Messages: 23
Registered: April 2007
Location: bangalore
Junior Member
how to send a mail using PL/SQL procedure?I need sample program
Re: how to send a mail using PL/SQL procedure [message #233766 is a reply to message #233765] Fri, 27 April 2007 07:19 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Search the forum.
This is been asked and answered numerous times
Re: how to send a mail using PL/SQL procedure [message #233770 is a reply to message #233765] Fri, 27 April 2007 07:24 Go to previous messageGo to next message
rajareddy_24
Messages: 23
Registered: April 2007
Location: bangalore
Junior Member
I am new to this forums.CAn you send the link regarding how to send a mail using PL/SQL.
Re: how to send a mail using PL/SQL procedure [message #233791 is a reply to message #233770] Fri, 27 April 2007 08:29 Go to previous messageGo to next message
Michel Cadot
Messages: 64109
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Do you see the "Search" button just below Oracle FAQ's page header?
Just click on it and fill the search field with your title.

Regards
Michel
Re: how to send a mail using PL/SQL procedure [message #233883 is a reply to message #233765] Fri, 27 April 2007 20:07 Go to previous message
kdipankar
Messages: 9
Registered: December 2006
Junior Member
Hi,
Pls find a sample code below.

DECLARE
l_mailhost VARCHAR2(64) := 'mail.mycompany.com';
l_from VARCHAR2(64) := 'me@mycompany.com';
l_subject VARCHAR2(64) := 'Test Mail';
l_to VARCHAR2(64) := 'you@mycompany.com';
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn := UTL_SMTP.open_connection(l_mailhost, 25);
UTL_SMTP.helo(l_mail_conn, l_mailhost);
UTL_SMTP.mail(l_mail_conn, l_from);
UTL_SMTP.rcpt(l_mail_conn, l_to);

UTL_SMTP.open_data(l_mail_conn);

UTL_SMTP.write_data(l_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || Chr(13));
UTL_SMTP.write_data(l_mail_conn, 'From: ' || l_from || Chr(13));
UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || l_subject || Chr(13));
UTL_SMTP.write_data(l_mail_conn, 'To: ' || l_to || Chr(13));
UTL_SMTP.write_data(l_mail_conn, '' || Chr(13));

FOR i IN 1 .. 10 LOOP
UTL_SMTP.write_data(l_mail_conn, 'This is a test message. Line ' || To_Char(i) || Chr(13));
END LOOP;

UTL_SMTP.close_data(l_mail_conn);

UTL_SMTP.quit(l_mail_conn);
END;
/


The UTL_SMTP package requires Jserver which can be installed by running the following scripts as SYS:
SQL> @$ORACLE_HOME/javavm/install/initjvm.sql
SQL> @$ORACLE_HOME/rdbms/admin/initplsj.sql
Previous Topic: Renaming Check Constraints in 8.1.7
Next Topic: date
Goto Forum:
  


Current Time: Mon Dec 05 08:44:47 CST 2016

Total time taken to generate the page: 0.10304 seconds