Home » Developer & Programmer » Forms » URGENT:-HOW TO SEND EMAIL FROM ORACLE FORMS 6i ?
|
Re: URGENT:-HOW TO SEND EMAIL FROM ORACLE FORMS 6i ? [message #83670 is a reply to message #83669] |
Sun, 23 November 2003 22:52 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
vimal
Messages: 46 Registered: February 2000
|
Member |
|
|
use this function i hope you can use it easily
FUNCTION SEND_MAIL_HTML(
server_name VARCHAR2,
sender_name VARCHAR2,
sender_mail VARCHAR2,
receiver_mail VARCHAR2,
subject VARCHAR2,
message VARCHAR2
)
RETURN NUMBER IS
PORT NUMBER :=25;
CONN UTL_SMTP.CONNECTION;
CRLF VARCHAR2(2) := CHR(13)||CHR(10);
SEND_DATA VARCHAR2(4000);
BEGIN
CONN := UTL_SMTP.OPEN_CONNECTION(SERVER_NAME,PORT);
UTL_SMTP.HELO(CONN,SENDER_NAME);
UTL_SMTP.MAIL(CONN,SENDER_MAIL);
UTL_SMTP.RCPT(CONN,RECEIVER_MAIL);
SEND_DATA := 'CONTENT-TYPE : text/html'||CRLF;
SEND_DATA := SEND_DATA||'SUBJECT :'||SUBJECT||CRLF||MESSAGE;
UTL_SMTP.DATA(CONN,SEND_DATA);
UTL_SMTP.QUIT(CONN);
RETURN 0;
EXCEPTION
WHEN OTHERS THEN
RETURN -1;
END;
|
|
|
Re: URGENT:-HOW TO SEND EMAIL FROM ORACLE FORMS 6i ? [message #83749 is a reply to message #83670] |
Sun, 07 December 2003 00:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Parul
Messages: 6 Registered: May 2002
|
Junior Member |
|
|
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_from varchar2 := 'oracle',
msg_to varchar2,
msg_subject varchar2 := 'E-Mail message from your database',
msg_text varchar2 := '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c := utl_tcp.open_connection('127.0.0.1', 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
EXCEPTION
when others then
raise_application_error(
-20000, 'Unable to send e-mail message from pl/sql because of: '||
sqlerrm);
END;
/
show errors
-- Examples:
set serveroutput on
exec send_mail(msg_to =>'you@yourdomain.com');
exec send_mail(msg_to =>'you@yourdomain.com', -
msg_text=>'Look Ma, I can send mail from plsql' -
);
|
|
|
Re: URGENT:-HOW TO SEND EMAIL FROM ORACLE FORMS 6i ? [message #83750 is a reply to message #83669] |
Sun, 07 December 2003 00:47 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Parul
Messages: 6 Registered: May 2002
|
Junior Member |
|
|
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_from varchar2 := 'oracle',
msg_to varchar2,
msg_subject varchar2 := 'E-Mail message from your database',
msg_text varchar2 := '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c := utl_tcp.open_connection('127.0.0.1', 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
EXCEPTION
when others then
raise_application_error(
-20000, 'Unable to send e-mail message from pl/sql because of: '||
sqlerrm);
END;
/
show errors
-- Examples:
set serveroutput on
exec send_mail(msg_to =>'you@yourdomain.com');
exec send_mail(msg_to =>'you@yourdomain.com', -
msg_text=>'Look Ma, I can send mail from plsql' -
);
|
|
|
|
Goto Forum:
Current Time: Sat Sep 07 05:19:55 CDT 2024
|