Send e-mail via Oracle Forms [message #501600] |
Wed, 30 March 2011 01:29 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sonia.ali
Messages: 40 Registered: April 2009 Location: Pakistan
|
Member |
|
|
Hello All,
I am new comer in oracle. I want to make form of
email sender.
Kindly make a form in Hr schema.
Thanks
SOnia ALi
|
|
|
|
Re: Email send [message #501728 is a reply to message #501600] |
Wed, 30 March 2011 23:10 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
sonia.ali
Messages: 40 Registered: April 2009 Location: Pakistan
|
Member |
|
|
Hello Friends,
I want to export employee table data where date = date1 and date2 in form.
and this export data automatically attach in mail specific email address like sonia.ali@gmail.com.
If some one could not understand.
Please check it.
Thanks
Sonia.Ali.
DECLARE
l_mailhost VARCHAR2(64) := 'mail.mycompany.com';
l_from VARCHAR2(64) := 'me@mycompany.com';
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.data(l_mail_conn, 'Single string message.' || CHR(13) || CHR(13));
UTL_SMTP.quit(l_mail_conn);
END;
/
Multi-line messages can be written by expanding the UTL_SMTP.DATA command using the UTL_SMTP.WRITE_DATA command as follows.
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));
-- Multi-line message simulated with a loop calling WRITE_DATA multiple times.
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.write_data(l_mail_conn, '' || CHR(13));
UTL_SMTP.close_data(l_mail_conn);
UTL_SMTP.quit(l_mail_conn);
END;
/
For emails with multiple recipients, simply call the RCPT procedure once for each separate email address.
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
|
|
|