final String ct = headers.getHeader("Content-Type", null);
boolean quotedPrintable = false;
for (Enumeration<?> e = headers.getAllHeaders(); e.hasMoreElements();) {
Header header = (Header) e.nextElement();
if (header.getName().equalsIgnoreCase("Content-Transfer-Encoding")) {
if (header.getValue().equalsIgnoreCase("binary")) {
att.setXOP(true);
} else if (header.getValue().equalsIgnoreCase("quoted-printable")) {
quotedPrintable = true;
}
}
att.setHeader(header.getName(), header.getValue());
}
if (quotedPrintable) {
DataSource source = new AttachmentDataSource(ct, new QuotedPrintableDecoderStream(stream));
att.setDataHandler(new DataHandler(source));