dcsimg
How can I read emails in different languages?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Gopinath_Sundharam
Posted On:   Friday, June 20, 2003 03:01 PM

Hi Gurus, I'm using JavaMail 1.3 and have written a small Java program to read emails at a regular intervals from a POP3/IMAP account and save the contents (from, subject, body etc) into a database. Then users will access this database from a web page and see the data. Emails from all languages (chinese, korean, japanese, dutch, french, english etc) can come into the POP3 account. So what I need to know is how to read the email messages correctly in their appropriate languages. In the database and the web page end, I have taken care of it using UTF-8 charset. I'm using MimeBodyPart and getInputStream() to read/parse the emails. Below is my code snippet: ===================    More>>

Hi Gurus,


I'm using JavaMail 1.3 and have written a small Java program to read emails at a regular intervals from a POP3/IMAP account and save the contents (from, subject, body etc) into a database. Then users will access this database from a web page and see the data.


Emails from all languages (chinese, korean, japanese, dutch, french, english etc) can come into the POP3 account. So what I need to know is how to read the email messages correctly in their appropriate languages. In the database and the web page end, I have taken care of it using UTF-8 charset.


I'm using MimeBodyPart and getInputStream() to read/parse the emails. Below is my code snippet:


===================

			
gstrSubject = objMessages[0].getSubject();
.....
.....
MimeBodyPart objMimeBodyPart = (MimeBodyPart)objMimePart;
InputStream objInputStream = objMimeBodyPart.getInputStream();
String[] objEncoding = objMimeBodyPart.getHeader("Content-Transfer-Encoding");
if (objEncoding != null && objEncoding.length > 0) {
objInputStream = MimeUtility.decode(objInputStream, objEncoding[0]);
}
int iChar = objInputStream.read();
while (iChar != -1) {
gstrBody += (char)iChar;
iChar = objInputStream.read();
}

===================


And I'm using the value/data in gstrSubject and gstrBody. The subject gets parsed correctly. I'm getting the correct subject in the respective language, BUT the email body comes out like this: "�ண�ய ப�்��்�ளில் த��ல்".


Any idea on how to do this? Any help would be great!





Thanks,

Gopi    <<Less
About | Sitemap | Contact