Rick McGuire wrote:
> 
> maho77 wrote:
>> Hello,
>>
>> it seems to me that the geronimo javamail implementation has some
>> encoding
>> problems. I use G2.1.1
>> I retrieve Message via POP3 and than I start parsing the parts in the
>> Message class. Everything works fine as long as I the mails are UTF-8
>> mails.
>> If there's an mail lets say with ISO-8859-1 the subject has the correct
>> encoding conversion, but not the content of the parts.
>>
>> If I try the same with the javamail implementation from sun, it works
>> well.
>>
>> Do I have to set some properties or something like that?
>>   
> This sounds like it's just a bug to me.  The POP3 implementation is 
> fairly new, and it's entirely possible there are some problems with 
> encodings....particularly since the javamail API docs are not entirely 
> clear on how some features should work.  If you can post a small sample 
> that can be run against both implementations, I'll gladly take a look at 
> it.
> 
> Rick
>> Mark
>>   
> 
> 
> 
Hello,

you need an email with e.g. ISO-8859-1 or ISO-8859-15 encoding
write in the subject: Test Ä-Ü-Ö
write the same in the body: Test Ä-Ü-Ö
check if it's a plain-text mail (it's easier to read this mail.

Retrieve this mail using the geronimo-mailapi. You can doublecheck the
result trying the sun javamail implementation. 
The subject ending is converted correctly. I think this is a result of bug:
GERONIMO-3842. But the encoding of the message-part only works with UTF-8.
There is no correct conversion to other charsets like ISO-8859-1.
This is how to receive the message and write into a file:
                Store store;
                Properties props = new Properties();
                Session session = Session.getInstance(props);
                FileOutputStream fos = null;
                
                try {
                        store = session.getStore("pop3");
                        store.connect(SERVER, USERNAME, PASSWORD);
                        // Get folder
                        Folder folder = store.getFolder("INBOX");
                        folder.open(Folder.READ_WRITE);
                        // Get directory
                        Message messages[] = folder.getMessages();
                        
                        for (int i = 0; i < messages.length; i++) {
                                ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
                                messages[i].writeTo(baos);
                                // write mail into a file
                                File file = new File("path_to_file");
                                fos = new FileOutputStream(file);
                                fos.write(baos.toByteArray());
                        }
                        folder.close(true);
                        store.close();
                } catch (NoSuchProviderException e) {
                        e.printStackTrace();
                } catch (MessagingException e) {
                        e.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                } finally { 
                        if ( fos != null ) 
                        try { fos.close(); } catch ( IOException e ) { } 
                } 

This is a sample mail created with mozilla thunderbirs:
>From - Fri May 30 15:59:50 2008
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
X-Mozilla-Keys:                                                                 
                
Message-ID: <[EMAIL PROTECTED]>
Date: Fri, 30 May 2008 15:59:50 +0200
From: Mark Hoffmann <[EMAIL PROTECTED]>
User-Agent: Thunderbird 2.0.0.12 (X11/20080226)
MIME-Version: 1.0
To: [EMAIL PROTECTED]
Subject: test =?ISO-8859-1?Q?=F6=E4=F6=FC?=
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Test öäü


I hope this helps,

Mark
-- 
View this message in context: 
http://www.nabble.com/Encoding-problem-in-geronimo-javamail-implementation-tp17595809s134p17599604.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.

Reply via email to