[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Send mails in Chinese characters

Posted on 2001-08-16
2
Medium Priority
?
1,302 Views
Last Modified: 2007-12-19

Hi all

I'm using UTL_SMTP package to send mails in a stored procedure.
My database character set is set to traditional Chinese
(ZHT16BIG5).
All Chinese characters received by the mail clients are converted to "?".

I think this may happen in all multi-byte characters.
Is there ever a way in PL/SQL to solve this problem ?

Thanks in advance.

0
Comment
Question by:AlbertYou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
dbalaski earned 200 total points
ID: 6395584


Hi,

From what I understand,  you are going to need to use the MIME format.  

As from this clip:
According to the Oracle documentation, the original SMTP protocol communicates using 7-bit
 ASCII. Using UTL_SMTP, all text data (in other words, those in VARCHAR2) will be converted to
 US7ASCII before it is sent over the wire to the server. When the target SMTP server supports
 8BITMIME extension, users of multi-byte databases may convert their non-US7ASCII, multi-byte
 VARCHAR2 data to RAW and use the write_raw_data() API to send multi-byte data using 8-bit
 MIME encoding.


How to send MIME format:
Put the following lines  right after the message subject that you send to utl_smtp.data.

 'MIME-Version: 1.0' || crlf ||
 'Content-type: text/plain; charset=iso-8859-1' || crlf ||
 'Content-transfer-encoding: 7bit' || crlf ||
 '' || crlf ||

(use the appropriate characterset in place of  "charset=iso-8859-1")

I think this might work -- give it a try...

dB
0
 
LVL 2

Author Comment

by:AlbertYou
ID: 6395784

Hi Laski

I have tried your way, it did not work.
I don't know what does
 "right after the message subject" mean.

However, your answer gives me a good hint that
this problem is derived from MIME format.

I have solved this problem by using the UTL_RAW package.
The following is my code.


DECLARE
   c utl_smtp.connection;
   PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
   BEGIN
      utl_smtp.write_raw_data(c, utl_raw.cast_to_raw(name || ': ' || header || utl_tcp.CRLF));
   END;
   PROCEDURE put_line ( p_line_text in varchar2) is
   begin
      utl_smtp.write_raw_data(c, utl_raw.cast_to_raw(p_line_text || utl_tcp.CRLF));
   end;
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', 'Chinese subject' );
   put_line(''); -- Do not remove this line, otherwise the mail content will be empty !!!
   put_line('Chinese messages');
   utl_smtp.close_data(c);
   utl_smtp.quit(c);
EXCEPTION
  WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
       utl_smtp.quit(c);
       raise_application_error(-20000,
         'Failed to send mail due to the following error: ' || sqlerrm);
END;


Thanks anyway.

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question