protected void closeStore(boolean success, Store store, Folder folder) throws MessagingException {
        try {
            if (folder != null && folder.isOpen()) {
                folder.close(success && flush);
            }
        } finally {
            if (store != null && store.isConnected()) {
                store.close();
            }
        }
    }