if (!contentTransferEncoding.equalsIgnoreCase("base64")
&& !contentTransferEncoding.equalsIgnoreCase("quoted-printable"))
{
if (!contentTransferEncoding.equalsIgnoreCase("binary"))
{
out = new CRLFOutputStream(out);
}
bodyPart.writeTo(out);
out.flush();
return;
}
//
// Special handling for Base64 or quoted-printable encoded
// body part - this is to get around JavaMail's habit of
// decoding and then re-encoding base64 data...
//
//
// Write headers
//
LineOutputStream outLine = new LineOutputStream(out);
for (Enumeration e = mimePart.getAllHeaderLines(); e.hasMoreElements();)
{
String header = (String)e.nextElement();
outLine.writeln(header);
}
outLine.writeln();
outLine.flush();
//
// Write raw content, performing canonicalization
//
InputStream inRaw = mimePart.getRawInputStream();
CRLFOutputStream outCRLF = new CRLFOutputStream(out);
byte[] buf = new byte[BUF_SIZE];
int len;
while ((len = inRaw.read(buf, 0, buf.length)) > 0)
{
outCRLF.write(buf, 0, len);
}
outCRLF.flush();
}
else
{
if (!defaultContentTransferEncoding.equalsIgnoreCase("binary"))
{
out = new CRLFOutputStream(out);
}
bodyPart.writeTo(out);
out.flush();