if(e.getType() == FolderEvent.MESSAGE_ADDED)
{
Message msg = e.getMessage();
try {
String htmlContent = "";
MessageObject msgObject = new MessageObject(msg, null );
//This can be Multipart if it has an attachment or MimeBodyPart if it doesn't.
Object content = msg.getContent();
if(content instanceof BodyPart) {
htmlContent = getHtmlContent((BodyPart)content);
msgObject.putField(MessageObject.FIELD_BODY, htmlContent);
}
notifyEmailReceived(_serviceName, msgObject);
} catch (Exception e1) {
System.out.println(e1.getMessage());
}