Hi Bob,
I had exactly your problem just the other day when testing UTL_SMTP out.
Please find below soething which works :o)
The answer is to make sure that there is one line containing
UTL_TCP.CRLF in it between where you want the header to finish and the
body to begin.
Cheers,
Norman.
CREATE OR REPLACE PROCEDURE email_test_message
IS
--
- MAILHOST is your own email server
- SENDER can actually be ficticious !
- RECIPIENT is obvious, and should really exist !
--
mailhost VARCHAR2(64) := 'lnewton.leeds.lfs.co.uk';
sender VARCHAR2(64) := 'TAMDB_at_lhawking.com';
recipient VARCHAR2(64) := 'Norman.Dunbar_at_lfs.co.uk';
mail_conn utl_smtp.connection;
BEGIN
mail_conn := utl_smtp.open_connection(mailhost, 25);
utl_smtp.helo(mail_conn, mailhost);
utl_smtp.mail(mail_conn, sender);
--
- The receivers are simply a list of people who WILL get the message.
- Putting a list of names in the CC entry makes no difference at all -
they won't get the message
- unless that are in a list of receivers.
--
utl_smtp.rcpt(mail_conn, recipient);
utl_smtp.rcpt(mail_conn, 'oracle_at_BountifulSolutions.co.uk');
--
- Write some stuff to appear in the FROM, TO, CC, SUBJECT fields of the
email.
- These are all of course, ficticious - SENDER above determines who
gets what.
--
utl_smtp.open_data(mail_conn);
utl_smtp.write_data(mail_conn, 'Subject: Message from Tam!'||
utl_tcp.CRLF);
utl_smtp.write_data(mail_conn, 'To: TAMDB Administrators'||
utl_tcp.CRLF);
utl_smtp.write_data(mail_conn, 'From: Busty Beryl - play with these
at your peril'|| utl_tcp.CRLF);
utl_smtp.write_data(mail_conn, 'CC: nick.bentley_at_lfs.co.uk'||
utl_tcp.CRLF);
--
- Separate the header from the body by a blank line.
- Otherwise, the body will be embedded in the header - not very useful
!
--
utl_smtp.write_data(mail_conn, utl_tcp.CRLF);
utl_smtp.write_data(mail_conn, /*CHR(10)||*/'Hello, this is TAMDB
calling - are you there ?' || utl_tcp.CRLF);
utl_smtp.close_data(mail_conn);
utl_smtp.quit(mail_conn);
EXCEPTION
WHEN OTHERS THEN
- Insert error-handling code here
NULL;
END;
/
Norman Dunbar
Database/Unix administrator
Lynx Financial Systems Ltd.
mailto:Norman.Dunbar_at_LFS.co.uk
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com
-------------------------------------
-----Original Message-----
From: Bob [mailto:bobs_at_yahoo.com]
Posted At: Tuesday, October 22, 2002 3:04 AM
Posted To: server
Conversation: Oracle Email Procedure
Subject: Oracle Email Procedure
When using the UTL_SMTP.Write_Data command, is there a trick to getting
text
into the body of a message. I am able to run a proc that will
sucessfully
send an eMail message to the right place with the correct subject text
but
nothing in the body. I have defined a short 25-30 character string as
the
message but the message arrives with a blank body. Any suggestions?
Thanks.
Bob :-)
Received on Tue Oct 22 2002 - 04:18:58 CDT