logger.info("Connected to mail service using " + cfg.getMailSessionProperties());
String searchDirectory = cfgProperties.getProperty("search.directory");
Folder folder = hasText(searchDirectory) ? store.getFolder(searchDirectory) : store.getFolder("inbox");
folder.open(Folder.READ_WRITE);
logger.info("Folder " + searchDirectory + " opened successfully");
Message[] messages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
logger.info("Found " + messages.length + " messages in " + folder.getFullName());
List<Message> processed = new ArrayList();
for (Message msg : messages) {
try {
processMessage(msg, cfg, toolBpmSession);