private void appendToMailbox(final InputStream message, final Date datetime, final Flags flagsToBeSet, final ImapSession session, final String tag, final ImapCommand command, final MessageManager mailbox, Responder responder, final MailboxPath mailboxPath) {
try {
final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
final SelectedMailbox selectedMailbox = session.getSelected();
final MailboxManager mailboxManager = getMailboxManager();
final boolean isSelectedMailbox = selectedMailbox != null && selectedMailbox.getPath().equals(mailboxPath);
final long uid = mailbox.appendMessage(message, datetime, mailboxSession, !isSelectedMailbox, flagsToBeSet);
if (isSelectedMailbox) {
selectedMailbox.addRecent(uid);
}
// get folder UIDVALIDITY
Long uidValidity = mailboxManager.getMailbox(mailboxPath, mailboxSession).getMetaData(false, mailboxSession, FetchGroup.NO_UNSEEN).getUidValidity();
unsolicitedResponses(session, responder, false);
// in case of MULTIAPPEND support we will push more then one UID
// here