store.connect(hostName, userName, password);
folder = store.getFolder(mailBox);
if (folder == null || !folder.exists()) {
throw new Exception("Folder not found or invalid: " + mailBox);
}
folder.open(Folder.READ_WRITE);
int msgCount = Math.min(folder.getMessageCount(),maxFetchSize);
DeliveryChannel channel = getDeliveryChannel();
MessageExchangeFactory mef = getExchangeFactory();
for(int i=1; i <= msgCount;i++) {
MimeMessage mailMsg = (MimeMessage) folder.getMessage(i);