How to construct a MimeMessage when receiving a email containing binary attachment

S

stephan

Hi,

We're trying to contruct a MimeMessage with content coming from an
email.
The email has two parts.
One text 8bit encoded ( content-transfer-encoding: 8bit)
One binary (gif file) ( content-transfer-encoding: binary).

Everything is fine for the text part but the binary part got
corrupted: all the LF bytes (0A) are changed to CRLF (0D 0A) which
corrupts the picture.

Is there something that needs to be done to prevent this conversion ?

We also tried 8bit as content-transfer-encoding for the binary
attachment without any more success.

TIA

--stephan
 
T

Thomas Weidenfeller

stephan said:
Everything is fine for the text part but the binary part got
corrupted: all the LF bytes (0A) are changed to CRLF (0D 0A) which
corrupts the picture.

You can't transport binary as-is in e-mail. Use an encoding, e.g.
base64. base64 is commonly understood by mime MUAs, so there shouldn't
be a problem at the receiver site to decode and display the image.

In general, I would suggest that you familiarize yourself with the
relevant e-mail and MIME RFCs.

/Thomas
 
S

steph

Thomas said:
You can't transport binary as-is in e-mail. Use an encoding, e.g.
base64. base64 is commonly understood by mime MUAs, so there shouldn't
be a problem at the receiver site to decode and display the image.

In general, I would suggest that you familiarize yourself with the
relevant e-mail and MIME RFCs.

/Thomas

Thanks for the answer. rfc 2045 defines 8bit and binary
content-transfer-encoding so i should be able to use them. But i do
agree that sending binary attachment may cause troubles to some mtas
(but i don't really care about that).

The question is what should i do to prevent MimeMessage class the do any
processiong on a binary attachment.

--stephan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top