private void addFlagsResponses(final ImapSession session, final SelectedMailbox selected, final ImapProcessor.Responder responder, boolean useUid, MessageRange messageSet, MessageManager mailbox, MailboxSession mailboxSession) throws MailboxException {
final Iterator<MessageResult> it = mailbox.getMessages(messageSet, FetchGroupImpl.MINIMAL, mailboxSession);
while (it.hasNext()) {
MessageResult mr = it.next();
final long uid = mr.getUid();
int msn = selected.msn(uid);
if (msn == SelectedMailbox.NO_SUCH_MESSAGE)
throw new MailboxException("No message found with uid " + uid);
final Flags flags = mr.getFlags();
final Long uidOut;
if (useUid) {
uidOut = uid;
} else {
uidOut = null;