// There's normally something in the headers
msg.guess7BitEncoding();
} else {
// Nothing in the header, try encoding detection
// on the message body
StringChunk text = msg.getMainChunks().textBodyChunk;
if(text != null) {
CharsetDetector detector = new CharsetDetector();
detector.setText( text.getRawValue() );
CharsetMatch match = detector.detect();
if(match.getConfidence() > 35) {
msg.set7BitEncoding( match.getName() );
}
}