sending email thru PL/SQL .. [message #184574] |
Thu, 27 July 2006 02:24 |
frank.svs
Messages: 162 Registered: February 2006
|
Senior Member |
|
|
Hi frns,
I have written a sample a stored procedure to send a somple mail which says "Good luck ..".
I am able to successfully send an email but i am not able give the Subject Line while sending an email.
Can anyone help me out in giving the subject line.
create or replace procedure p1
as
conn utl_smtp.connection;
begin
conn := utl_smtp.open_connection('smtp.xxx.com',25);
utl_smtp.helo(conn, 'smtp.xxx.com');
utl_smtp.mail(conn,'sender@companyname.com');
utl_smtp.rcpt(conn, 'frank.svs@gmail.com');
utl_smtp.open_data(conn);
utl_smtp.write_data(conn, UTL_TCP.CRLF || 'Good Luck .......');
utl_smtp.close_data(conn);
utl_smtp.quit(conn);
dbms_output.put_line('*** Mail has been Sucessfully sent to the intended recepient ***');
EXCEPTION
WHEN others THEN
utl_smtp.close_data(conn);
utl_smtp.quit(conn);
dbms_output.put_line('!!! ERROR OCCURED !!!');
end;
/
Thanks and Regards,
frank
|
|
|
Re: sending email thru PL/SQL .. [message #184586 is a reply to message #184574] |
Thu, 27 July 2006 02:57 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
From the doumentation in the package header of UTL_SMTP (what an odd place to think of looking) comes this sample piece of code.
Spotting the exact line that sets the Subject is left as an exercise for the reader.
BEGIN
c := utl_smtp.open_connection('smtp-server.acme.com');
utl_smtp.helo(c, 'foo.com');
utl_smtp.mail(c, 'sender@foo.com');
utl_smtp.rcpt(c, 'recipient@foo.com');
utl_smtp.open_data(c);
send_header('From', '"Sender" <sender@foo.com>');
send_header('To', '"Recipient" <recipient@foo.com>');
send_header('Subject', 'Hello');
utl_smtp.write_data(c, utl_tcp.CRLF || 'Hello, world!');
utl_smtp.close_data(c);
utl_smtp.quit(c);
EXCEPTION
|
|
|