Good morning everybody.
I have a problem with mail attachements which have the Content-Transfer-Encoding „quoted-printable“.
I use an Email file myEMail.eml with an attachment (myPDF.pdf), generated with Windows Live Mail.
Content-Type: application/pdf;
name="=?utf-8?B?0JPQvtGA0LHQsNGH0ZHQsiwg0JzQuNGF0LDQuNC7INCh0LXRgNCz0LXQtQ==?=
=?utf-8?B?0LLQuNGHIChPUklHSU5BTCkucGRm?="
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="=?utf-8?B?0JPQvtGA0LHQsNGH0ZHQsiwg0JzQuNGF0LDQuNC7INCh0LXRgNCz0LXQtQ==?=
=?utf-8?B?0LLQuNGHIChPUklHSU5BTCkucGRm?="
In our scenario, we remove all attachmens and store the „raw“ EML and the attachments separately.
Then if I merge the mail and add the attachments with the original attributes, the PDF is corrupted and can’t be opened.
A comparison of the original EML and the merged shows many differences at the attached PDF (but the separate stored PDF is byte indentically with the PDF from the original EML).
If I use „base64“ as Content-Transfer-Encoding, everything will be fine, of course.
But I need to restore the EML with the original attributes.
Is there anyone who knows of this beaviour?
Many thanks
Dirk
Code snippet for adding attachments
EMLDatasource ds = new EMLDatasource(tmpBlob, null,
contetType);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(ds));
// if ("quoted-printable".equals(transferEncoding) == true) {
// transferEncoding = "base64";
// }
messageBodyPart.setHeader(CONTENT_TRANSFER_ENCODING,
transferEncoding);
messageBodyPart.setDescription(description);
messageBodyPart.setDisposition(disposition);
messageBodyPart.setHeader(CONTENT_ID, contentID);
messageBodyPart.setHeader(CONTENT_TYPE, contetType);
Multipart mp.addBodyPart(messageBodyPart);
Code snippet for storing EML
CustomizedMimeMessage message = new CustomizedMimeMessage(
null, emlBlob.getInputStream(true));
message.saveChanges();
OutputStream out = blob.getOutputStream();
try {
message.writeTo(out);
} finally {
if (out != null) {
out.close();
}
}