// ---------------------------------------------------------------------------
public MimePart getBody ()
throws ParseException, MessagingException, IOException {
MimePart oRetVal = null;
if (DebugFile.trace) {
DebugFile.writeln("Begin DBMimeMessage.getBody([MimeMessage])");
DebugFile.incIdent();
}
Object oContent = null;
try {
oContent = super.getContent();
}
catch (Exception xcpt) {
DebugFile.decIdent();
throw new ParseException("MimeMessage.getContent() ParseException cause " + xcpt.getClass().getName() + " " + (xcpt.getMessage()==null ? "" : xcpt.getMessage()));
}
if (DebugFile.trace) {
if (null==oContent)
DebugFile.writeln("message content is null");
else
DebugFile.writeln("message content class is " + oContent.getClass().getName());
}
String sContentClass = oContent.getClass().getName();
if (sContentClass.equals("javax.mail.internet.MimeMultipart")) {
MimeMultipart oParts = (MimeMultipart) oContent;
int iParts = oParts.getCount();
MimePart oPart;
String sType, sPrevType, sNextType;
for (int p=0; p<iParts; p++) {
oPart = (MimePart) oParts.getBodyPart(0);
sType = oPart.getContentType().toUpperCase();
if (p<iParts-1)
sNextType = ((MimeBodyPart) oParts.getBodyPart(p+1)).getContentType().toUpperCase();
else
sNextType = "";
if (p>0 && iParts>1)
sPrevType = ((MimeBodyPart) oParts.getBodyPart(p-1)).getContentType().toUpperCase();
else
sPrevType = "";
// If a message has a dual content both text and html ignore the text and show only HTML
if ((iParts<=1) && (sType.startsWith("TEXT/PLAIN") || sType.startsWith("TEXT/HTML"))) {
if (DebugFile.trace) DebugFile.writeln("parts=" + String.valueOf(iParts) + ", content-type=" + oPart.getContentType());
oRetVal = oPart;
break;
}
else if (((p==0) && (iParts>1) && sType.startsWith("TEXT/PLAIN") && sNextType.startsWith("TEXT/HTML"))) {
if (DebugFile.trace) DebugFile.writeln("parts=" + String.valueOf(iParts) + ", part=0, content-type=" + oPart.getContentType() + ", next-type=" + sNextType);
oRetVal = ((MimeBodyPart) oParts.getBodyPart(p+1));
break;
}
else if ((p==1) && sType.startsWith("TEXT/PLAIN") && sPrevType.startsWith("TEXT/HTML")) {
if (DebugFile.trace) DebugFile.writeln("parts=" + String.valueOf(iParts) + ", part=1, content-type=" + oPart.getContentType() + ", prev-type=" + sPrevType);
oRetVal = ((MimeBodyPart) oParts.getBodyPart(p-1));
break;
}
else {
oRetVal = DBMimePart.getMessagePart (oPart, p);