문제

I need to convert MimeMessage into byte array, but while converting some characters are not coded correctly. Code lookis like this:

// message is MimeMessage
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.writeTo(baos);
byte[] bytes = baos.toByteArray(); 

This conversion doesn't work correctly, as output I'm receving wrong formatted email body:

<html xmlns=3D"http://www.w3.org/1999/xhtml" xml:lang=3D"en" lang=3D"en"
   >
<body style=3D"background-color: #ffffff;"  >

...

3D should not be present in this (xmlns=3D"http:). I could remove it but this is not a safe solution, I might accidentally remove some content from the email body.

Any tip may help.

도움이 되었습니까?

해결책

Your mime message contains Quoted-Printable Encoding, see MIME RFC 1521, so you need to decode it before saving it.

You should be able to use javax.mail.internet.MimeUtility.decode for this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top