Parser oPrsr = Parser.createParser(oHtmlBuff.toString(), getEncoding());
StringBean oStrBn = new StringBean();
try {
oPrsr.visitAllNodesWith (oStrBn);
} catch (ParserException pe) {
throw new MessagingException(pe.getMessage(), pe);
}
// Code for HTML parser 1.4
// oStrBn.setInputHTML(oHtmlBuff.toString());
oBuffer.append(oStrBn.getStrings());
}
else {
if (DebugFile.trace) DebugFile.writeln("Multipart = DBMimeMessage.getParts()");
Multipart oParts = getParts();
final int iParts = oParts.getCount();
MimePart oPart;
int p;
for (p=0; p<iParts && !bHasPlainTextVersion; p++) {
oPart = (MimePart) oParts.getBodyPart(p);
String sType = oPart.getContentType();
if (null!=sType) sType=sType.toLowerCase();
String sDisp = oPart.getDisposition();
if (null==sDisp) sDisp="inline"; else if (sDisp.length()==0) sDisp="inline";
if (DebugFile.trace) DebugFile.writeln("scanning part " + String.valueOf(p) + sDisp + " " + sType.replace('\r',' ').replace('\n', ' '));
if (sType.startsWith("text/plain") && sDisp.equalsIgnoreCase("inline")) {
bHasPlainTextVersion = true;
DBMimePart.parseMimePart (oBuffer, null,
getFolder().getName(),
getMessageID()!=null ? getMessageID() : getContentID(),
oPart, p);
}
}
if (DebugFile.trace) {
if (bHasPlainTextVersion)
DebugFile.writeln("MimeMultipart has plain text version at part " + String.valueOf(p));
else
DebugFile.writeln("MimeMultipart has no plain text version, converting part 0 from HTML");
}
if (!bHasPlainTextVersion) {
oPart = (MimePart) oParts.getBodyPart(0);
StringBuffer oHtml = new StringBuffer();
DBMimePart.parseMimePart (oHtml, null, getFolder().getName(), getMessageID()!=null ? getMessageID() : getContentID(), oPart, 0);
Parser oPrsr = Parser.createParser(oHtml.toString(), getEncoding());
StringBean oStrBn = new StringBean();
try {
oPrsr.visitAllNodesWith (oStrBn);
} catch (ParserException pe) {
throw new MessagingException(pe.getMessage(), pe);
}
// Code for HTML parser 1.4
// oSB.setInputHTML(oHtml.toString());