Home » SQL & PL/SQL » SQL & PL/SQL » email no content
email no content [message #183525] Fri, 21 July 2006 04:06 Go to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
i'm trying to use utl_smtp on 10g XE, with the code below,



create or replace procedure send_emsg 
as
   mailhost varchar2(64) := '192.168.64.30';
   sender   varchar2(64) := 'ryan_restua@atsc.com.ph';
   rcpt     varchar2(64) := 'underoath_rrkr@yahoo.com';
   m_cnt    utl_smtp.connection;
begin
   m_cnt := utl_smtp.open_connection(host => mailhost
                                    ,port => 25);
   utl_smtp.helo(m_cnt, mailhost);
   utl_smtp.mail(m_cnt, sender);
   utl_smtp.rcpt(m_cnt, rcpt);
   utl_smtp.open_data(m_cnt);
   utl_smtp.write_data(m_cnt, 'This is a test message tuaman'||  chr(13) || chr(10));
   utl_smtp.write_data(m_cnt,'still no message!'||  chr(13) || chr(10));
   utl_smtp.close_data(m_cnt);
end;



when i run it, i got no message content, a blank email =) i tried receiving the mail in Lotus Notes, Gmail, & Yahoo, but still all receives just a blank email =)
Re: email no content [message #184395 is a reply to message #183525] Wed, 26 July 2006 07:15 Go to previous messageGo to next message
sanka_yanka
Messages: 184
Registered: October 2005
Location: Kolkata
Senior Member

Use
UTL_SMTP.DATA(m_cnt, 'This is a test message tuaman'||  chr(13) || chr(10));


insted of
utl_smtp.write_data(m_cnt, 'This is a test message tuaman'||  chr(13) || chr(10));


and Use
  UTL_SMTP.QUIT(m_cnt);

insted of
utl_smtp.close_data(m_cnt);


Thanks & Regards
Sanka
Re: email no content [message #184520 is a reply to message #184395] Wed, 26 July 2006 20:27 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
tried this


create or replace procedure send_emsg 
as
   mailhost varchar2(64) := '192.168.64.30';
   sender   varchar2(64) := 'ryan_restua@atsc.com.ph';
   rcpt     varchar2(64) := 'ehegagoka@gmail.com';
   m_cnt    utl_smtp.connection;
begin
   m_cnt := utl_smtp.open_connection(host => mailhost
                                    ,port => 25);
   utl_smtp.helo(m_cnt, mailhost);
   utl_smtp.mail(m_cnt, sender);
   utl_smtp.rcpt(m_cnt, rcpt);   
   utl_smtp.data(m_cnt, 'This is a test message tuaman'||  chr(13) || chr(10));
   utl_smtp.quit(m_cnt);
end;



but still no message body.
Re: email no content [message #184628 is a reply to message #184520] Thu, 27 July 2006 04:46 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
i've been searching to this forum and still cant find why my email has no message, the usual code like mine or this link

http://www.orafaq.com/forum/m/168606/74539/?srch=utl_smtp#msg_168606

executes but it has no content, i've tried the one HTML_EMAIL by tom kyte, but why when i write a simple plain text message it has no body, what could be the error in the code?
Re: email no content [message #184631 is a reply to message #184628] Thu, 27 July 2006 04:51 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I think @Sanka_yanka may have got their advice wrong.
From the documentation in the UTL_SMTP header, you need to end your mail with:

 utl_smtp.close_data(c);
 utl_smtp.quit(c);
Re: email no content [message #184642 is a reply to message #184631] Thu, 27 July 2006 05:19 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
cant really make it work using this still no message content, is this working on your side?


create or replace procedure send_emsg 
as
   mailhost varchar2(64) := '192.168.64.30';
   sender   varchar2(64) := 'ryan_restua@atsc.com.ph';
   rcpt     varchar2(64) := 'ehegagoka@gmail.com';
   m_cnt    utl_smtp.connection;
begin
   m_cnt := utl_smtp.open_connection(host => mailhost
                                    ,port => 25);
   utl_smtp.helo(m_cnt, mailhost);
   utl_smtp.mail(m_cnt, sender);
   utl_smtp.rcpt(m_cnt, rcpt);
   utl_smtp.open_data(m_cnt);
   utl_smtp.write_data(m_cnt, 'This is a test message tuaman'||  chr(13) || chr(10));
   utl_smtp.write_data(m_cnt,'has a message!'||  chr(13) || chr(10));
   utl_smtp.close_data(m_cnt);
   utl_smtp.quit(m_cnt);
end;

Re: email no content [message #184644 is a reply to message #184642] Thu, 27 July 2006 05:27 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Lets just check it's not the Chr(13) and chr(10) that are causing the problem.

Replace your Write_data with this:

utl_smtp.write_data(m_cnt, utl_tcp.CRLF || 'Hello, world!');


Re: email no content [message #184839 is a reply to message #184644] Fri, 28 July 2006 05:07 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
thanks sir JRowbottom and to all =) it worked at last!!!
Re: email no content [message #184840 is a reply to message #184839] Fri, 28 July 2006 05:11 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
So what was the change that let it work?

There have been a few queries like this one, and it would be nice to know how you solved the problem.
Re: email no content [message #184970 is a reply to message #184840] Sat, 29 July 2006 03:34 Go to previous message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!
replacing chr with utl_tcp.CRLF solved it =)
Previous Topic: utl_mail.send to/from format/appearance
Next Topic: No of days approaching birthday
Goto Forum:
  


Current Time: Wed Dec 07 10:58:44 CST 2016

Total time taken to generate the page: 0.13531 seconds