* @throws MessagingException
* @throws IOException
*/
private static ByteArrayOutputStream getBodyAsStream(MimeMessage oMsg)
throws MessagingException,IOException {
MimePart oText = null;
ByteArrayOutputStream byStrm;
if (DebugFile.trace) {
DebugFile.writeln("Begin DBFolder.getBodyAsStream([MimeMessage])");
DebugFile.incIdent();
if (null!=oMsg) DebugFile.writeln(oMsg.getClass().getName());
else DebugFile.writeln("MimeMessage is null");
}
if (oMsg.getClass().getName().equals("com.knowgate.hipermail.DBMimeMessage"))
// If appended message is a DBMimeMessage then use DBMimeMessage.getBody()
// for getting HTML text part or plain text part of the MULTIPART/ALTERNATIVE
oText = ((DBMimeMessage) oMsg).getBody();
else {
// Else if the appended message is a MimeMessage use standard Java Mail getBody() method
oText = new DBMimeMessage(oMsg).getBody();
} // fi
if (DebugFile.trace) {
DebugFile.writeln("MimePart encoding is "+oText.getEncoding());
DebugFile.writeln("MimePart size is "+String.valueOf(oText.getSize()));
}
// *************************************************************************
// Initialize a byte array for containing the message body
if (DebugFile.trace) DebugFile.writeln("ByteArrayOutputStream byOutStrm = new ByteArrayOutputStream("+String.valueOf(oText.getSize()>0 ? oText.getSize() : 8192)+")");
byStrm = new ByteArrayOutputStream(oText.getSize()>0 ? oText.getSize() : 8192);
oText.writeTo(byStrm);
if (DebugFile.trace) {
DebugFile.decIdent();
DebugFile.writeln("End DBFolder.getBodyAsStream() : " + Gadgets.left(new String(byStrm.toByteArray()),100));
}