for (int i = 0; i < ranges.size(); i++) {
mailbox.getMessages(ranges.get(i), resultToFetch, mailboxSession, new MessageCallback() {
public void onMessages(Iterator<MessageResult> it) throws MailboxException {
while (it.hasNext()) {
final MessageResult result = it.next();
try {
final FetchResponse response = builder.build(fetch, result, mailbox, session, useUids);
responder.respond(response);
} catch (ParseException e) {
// we can't for whatever reason parse the message so
// just skip it and log it to debug
session.getLog().debug("Unable to parse message with uid " + result.getUid(), e);
} catch (MessageRangeException e) {
// we can't for whatever reason find the message so
// just skip it and log it to debug
session.getLog().debug("Unable to find message with uid " + result.getUid(), e);
}
}
}
});
}