mail attachement content trnsfer encoding 8bit , 7bit

Good morning to everybody.

I have a problem reading mail attachement.

When the attachement is 8bit encoded the exadecimal char "3D" is write in a file as "0D". This is wrong

When the attachement is 7bit encoded the exadecimal char "3D" is write in a file as "3D" . Thi is right

Is there anyone who knows why of this beaviour?

Many thanks

[374 byte] By [ElisaCappaa] at [2007-11-27 5:29:11]
# 1
Do you have an example or a test program that reproduces the problem?3D is an ASCII "=", 0D is CR. It's unlikely these are being handledincorrectly. Possibly the message is encoded incorrectly.
bshannona at 2007-7-12 14:52:07 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

I'm using the msgshow.java that is the example included in the java mail library.

Attachement downloaded with JavaMail (the bad one):

伀 3D ==> 0D (CR)

2007-05-15;18.11.26;978;000469,00;380;Italy

;LUISA SPAGNOLI NAPOLI IT;34009575;8036527;5651;00;

Attachement downloaded with outlook (the good one):

伀 3D not translated

2007-05-15;18.11.26;978;000469,00;380;Italy=

;LUISA SPAGNOLI NAPOLI IT;34009575;8036527;5651;00;

Here the properties of the mail message:

Microsoft Mail Internet Headers Version 2.0

Received: from EXSMTP-IN2.sede.corp.sanpaoloimi.com ([10.244.7.21]) by EVS01.sede.corp.sanpaoloimi.com with Microsoft SMTPSVC(6.0.3790.2499);

Mon, 28 May 2007 08:09:14 +0200

Received: from secgw-b-e02.intesabci.it ([172.19.0.27]) by EXSMTP-IN2.sede.corp.sanpaoloimi.com with Microsoft SMTPSVC(6.0.3790.2499);

Mon, 28 May 2007 08:09:13 +0200

Received: MHUBINT

Received: FW

Received: from mail1.ssb.it ([192.106.129.13])

by mailbox.intesabci.it with SMTP id l4S696n5006757

for <aldo.cappa@intesasanpaolo.com>; Mon, 28 May 2007 08:09:09 +0200

Received: (qmail 11377 invoked by uid 509); 28 May 2007 06:02:04 -0000

Received: from 127.0.0.1 by Imhotep (envelope-from <sto_auto@ssb.it>, uid 501) with qmail-scanner-2.01

(spamassassin: 3.1.3.

Clear:RC:1(127.0.0.1):.

Processed in 0.078893 secs); 28 May 2007 06:02:04 -0000

Mon, 28 May 2007 08:02:03 +0200 (CEST)

(Postfix) with SMTP id 6798F34257;Mon, 28 May 2007 08:02:03 +0200 (CEST)

to: <aldo.cappa@intesasanpaolo.com>,

from: <sto_auto@ssb.it>

subject: 28 May 2007 08:00 PS12 FROD-ATM1

MIME-Version: 1.0

Content-Type: multipart/mixed;

boundary="P=_NextPart_000_01BD3BAF.A762FD80"

Date: Mon, 28 May 07 08:00:27 B

Message-Id: <20070528060203.6798F34257@Mail1.ssb.it>

Return-Path: sto_auto@ssb.it

X-OriginalArrivalTime: 28 May 2007 06:09:13.0674 (UTC) FILETIME=[B707A2A0:01C7A0EE]

--P=_NextPart_000_01BD3BAF.A762FD80

CONTENT-TYPE: TEXT/PLAIN; CHARSET="US-ASCII"

Content-Transfer-Encoding: 8bit

--P=_NextPart_000_01BD3BAF.A762FD80

Content-Type: text/plain; charset=us-ascii; name="SPIMI.TXT"

Content-Disposition: attachment

Content-Transfer-Encoding: quoted-printable

X-MIME-Autoconverted: from 8bit to quoted-printable by mailbox.intesabci.it id l4S696n5006757

--P=_NextPart_000_01BD3BAF.A762FD80

CONTENT-TYPE: TEXT/PLAIN; CHARSET="US-ASCII"

Content-Transfer-Encoding: 8bit仼仼仼仼 I think the problem is here

--P=_NextPart_000_01BD3BAF.A762FD80--

ElisaCappaa at 2007-7-12 14:52:07 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Your sample message doesn't include either the "good" or the "bad"

data you listed.

Your message has several parts, I don't know which part contains the

data that's causing the problem for you.

Once of the parts is encoded in quoted-printable form. In that encoding,

an '=' at the end of the line means the line is continued on the next line

and the '=' should be removed and the lines joined. JavaMail does this

decoding for you. That part also claims to have been converted from

8bit to quoted-printable by your mail server. Possibly your mail server is

doing the conversion incorrectly.

bshannona at 2007-7-12 14:52:07 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Attachement downloaded with JavaMail (the bad one):

2007-05-15;18.11.26;978;000469,00;380;Italy

;LUISA SPAGNOLI NAPOLI IT;34009575;8036527;5651;00;

Attachement downloaded with outlook (the good one):

2007-05-15;18.11.26;978;000469,00;380;Italy=

;LUISA SPAGNOLI NAPOLI IT;34009575;8036527;5651;00;

The previous lines are the strings contained in the attachement .txt file.

The first is the string where the hex char "3D" is translated into "0D" and the attachemet is downloaoded with javamail api

The second one is the string where "3D" is not translated so you can see the "=" after "Italy" and the attchement is downloaded with outlook

The javamail api does't translate the "3D" in "0D" when I receive a mail msg with "Content-Transfer-Encoding: 7bit"

Thanks for you patience

ElisaCappaa at 2007-7-12 14:52:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
You're repeating yourself without adding any new information.I need to see the entire message with the attachment that doesn't work,and the entire message with the attachment that does work. Post themhere or send them as attachments to javamail@sun.com.
bshannona at 2007-7-12 14:52:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

I'm sorry but if I send you the email with the attachement the problem disapeared.

But now I discovered that if I resend me the received message with the attachement using my exchange server the attachement is downloaded correctly.

Second thing I have discovered that it is not the write() istruction that does not write correctly the readed byte but the read() istruction that doesn't read correctly the byte of the 7 bit encoded file.

See you soon

ElisaCappaa at 2007-7-12 14:52:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...