Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Oracle Email Procedure

4 views
Skip to first unread message

Bob

unread,
Oct 21, 2002, 10:03:41 PM10/21/02
to
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 :-)

Jan Schaefer

unread,
Oct 22, 2002, 3:29:40 AM10/22/02
to
Bob schrieb:

The first two lines are reserved for the Subject. Try to insert a blank
line after the Subject.

Jan

Norman Dunbar

unread,
Oct 22, 2002, 5:18:58 AM10/22/02
to
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) := 'TA...@lhawking.com';
recipient VARCHAR2(64) := 'Norman...@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, 'ora...@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.b...@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...@LFS.co.uk
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com
-------------------------------------

Vladimir M. Zakharychev

unread,
Oct 22, 2002, 6:03:38 AM10/22/02
to
You may want to try our PSP_Mail package - it can be used to send virtually
any kind of email from Oracle8i 8.1.6+, target multiple recipients in one
call, attach unlimited number of BLOBs or external OS files to a message,
and more. You can download documentation and the suite itself at
http://www.dpsp-yes.com/dpsp/prod/!go?ln=ndownloads

hth.

--
Vladimir Zakharychev (b...@dpsp-yes.com) http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"Bob" <bo...@yahoo.com> wrote in message news:1m2t9.549845$v53.23...@news3.calgary.shaw.ca...

Hilary Band

unread,
Oct 22, 2002, 11:30:22 AM10/22/02
to
"Bob" <bo...@yahoo.com> wrote in message news:<1m2t9.549845$v53.23...@news3.calgary.shaw.ca>...

Hi Bob

We have implemented a package using UTL_SMTP which works successfully.
We pass the body of the message into the procedure as a parameter,
along with the To address, From address and Subject. Within the
procedure we concatenate all these parameters, including the message
body, into one string. We then use UTL_SMTP.WRITE_DATA to send the
string to the mail host.

The procedure is based on the example which you can find on Metalink.

HTH

H

NorwoodThree

unread,
Oct 22, 2002, 7:21:54 PM10/22/02
to
There's no need for this commercial waste. You should be able to do
whatever you want with the UTL_SMTP package.

Bob

unread,
Oct 22, 2002, 10:21:11 PM10/22/02
to
Thanks to Jan, Norman, Vladimir, Norwood and Hilary. There is some good
information to check out tomorrow when I get back to the office and the
network. Sounds like I should be able to get things working, I will let you
know. And thanks for the opportunity to check out a commercial option., it
never hurts to be aware. Again, thanks all.

Bob :-)


"Bob" <bo...@yahoo.com> wrote in message
news:1m2t9.549845$v53.23...@news3.calgary.shaw.ca...

Bob

unread,
Oct 23, 2002, 10:29:31 PM10/23/02
to
Success. Once again, thanks to all. The idea that the SMTP package looked
for a CRLF between the header info and the body held true. As soon as I
seperated the two with an extra CLRF everything fell into place.

Bob :-)

"Bob" <bo...@yahoo.com> wrote in message
news:1m2t9.549845$v53.23...@news3.calgary.shaw.ca...

Vladimir M. Zakharychev

unread,
Oct 24, 2002, 1:37:16 AM10/24/02
to
Sorry if I offended anyone with that "commercial waste", though I believe
the package is not really that bad. :) I agree that if you put some effort into
it, you can do whatever you want with UTL_SMTP, and our package does use
UTL_SMTP for transport, but that effort may be substantial if you need to go
beyond basic stuff, and our solution may appear cheaper than developer's time
put into developing comparable functionality. Why reinvent the wheel?

--
Vladimir Zakharychev (b...@dpsp-yes.com) http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"NorwoodThree" <norwoo...@my-deja.com> wrote in message
news:ba03e2c.0210...@posting.google.com...

Norman Dunbar

unread,
Oct 24, 2002, 3:34:05 AM10/24/02
to
Hi Bob,

been there, had the problem, found the fix !

The demo routine in the Oracle manual neglegts the CRLF between the
header & body - which can be a tad upsetting, if you don't know what to
do to fix it !

Cheers,
Norman.

-------------------------------------
Norman Dunbar
Database/Unix administrator
Lynx Financial Systems Ltd.
mailto:Norman...@LFS.co.uk
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com
-------------------------------------


-----Original Message-----
From: Bob [mailto:bo...@yahoo.com]
Posted At: Thursday, October 24, 2002 3:30 AM
Posted To: server
Conversation: Oracle Email Procedure

0 new messages