OTN UTL_SMTP Code Examples
Robert Pang, September 26, 2003 - 1:14 pm UTC
Problem with UTL_SMTP for spanish character
Eduardo, February 08, 2006 - 10:43 am UTC
Hi, I´m using UTL_SMTP for sending html mail but some characters ( like ñ, ', " ) are not displaying correctly. Can you help me?
mesg:=
'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || utl_tcp.CRLF ||
'From: ' || from_name || utl_tcp.CRLF ||
'Subject: ' || subject || utl_tcp.CRLF ||
'To: ' || to_name || utl_tcp.CRLF ||
'Mime-Version: 1.0' || utl_tcp.CRLF ||
'Content-Type: text/html; charset=UTF-8'||utl_tcp.CRLF;
utl_smtp.write_data ( conn, mesg );
utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(UTL_TCP.CRLF||message || utl_tcp.CRLF));
February 08, 2006 - 10:58 am UTC
well, you are not really using utf-8 here are you?
you are sending the mail in 7bits and 8bits?? you are using write_data and write_RAW_data? you just use one or the other.
and only if your smtp server is capable of dealing with that (many would expect you to encode this 8bit data using base 64 or something)
Problem with UTL_SMTP for spanish character
Eduardo, February 08, 2006 - 3:28 pm UTC
Hi Tom thanks for your answer and I´ll use write_raw_data in my code but I don´t understand you about 7 or 8 bits.
February 09, 2006 - 4:57 am UTC
your extended characters with tildas and such are 8 bit characters, smtp is a 7bit protocol (like US7ASCII, only 7 bits are used). IF your smtp server supports it, it MIGHT be able to take the 8bit data with the write raw data routine, if not you'll have to base64 encode the data (which uses only 7bit characters)
Problem with UTL_SMTP for spanish character
Eduardo, February 09, 2006 - 7:45 pm UTC
Could you provide me an example using the code above?
Thanks a lot.
February 10, 2006 - 12:34 pm UTC
the link provided by Robert Pang above does - have you checked out that code sample?
A reader, March 17, 2008 - 4:53 am UTC
Even i am facing the same problem. I have a procedure which sends mail using utl_smtp. Now the problem is , in the mail body, some characters like -, ' are replaced by this "?".
Plz let me know how to resolve this.
March 24, 2008 - 8:43 am UTC
please read about the SMTP protocol, we are not doing the replacement - it is. some email servers will break lines at a certain character boundary and put in a line continuation character (a dash or equals sign), they are all supposed to be 7 bit ascii by default and so on.
utl_smtp + special characters in the subject
A reader, April 16, 2009 - 8:16 am UTC
Hi Tom,
I am sending special characters both in Subject and in
the body of the mail. I use utl_smtp.write_raw_data(l_conn,utl_RAW.CAST_TO_RAW(l_data)..
I also specified utl_smtp.WRITE_DATA('Content Type : text/xml characterset=UTF8);
The issue is, i am able to see the content correctly in the body of the mail..But, in the Subject, the special character is appearing as junk
Please help me out.
Thanks & Regards
A.Gopal
gopal_ananthanarayanan@satyam.com