Message msg = mMailbox.addMessage(getContext(), pm, folder.getId(), false, flagMask, tagStr.toString());
Message msg = mMailbox.addMessage(getContext(), pm, folder.getId(), true, flagMask, tagStr.toString());
    boolean doAPPEND(String tag, String folderName, List<String> flagNames, Date date, byte[] content) throws IOException {        if (!checkState(tag, ImapSession.STATE_AUTHENTICATED))            return CONTINUE_PROCESSING;        // server uses UNIX time, so range-check specified date (is there a better place for this?)        if (date != null && date.getTime() > Integer.MAX_VALUE * 1000L) {            ZimbraLog.imap.info("APPEND failed: date out of range");            sendNO(tag, "APPEND failed: date out of range");            return CONTINUE_PROCESSING;        }        ArrayList<Tag> newTags = new ArrayList<Tag>();        StringBuffer appendHint = new StringBuffer();        try {            synchronized (mMailbox) {                Folder folder = mMailbox.getFolderByPath(getContext(), folderName);                if (!ImapFolder.isFolderVisible(folder)) {                    ZimbraLog.imap.info("APPEND failed: cannot APPEND to folder: " + folderName);                    sendNO(tag, "APPEND failed");                    return CONTINUE_PROCESSING;                } else if (!ImapFolder.isFolderWritable(folder)) {                    ZimbraLog.imap.info("APPEND failed: folder is READ-ONLY: " + folderName);                    sendNO(tag, "APPEND failed: mailbox is READ-ONLY");                    return CONTINUE_PROCESSING;                }                byte sflags = 0;                int flagMask = Flag.FLAG_UNREAD;                StringBuffer tagStr = new StringBuffer();                if (flagNames != null) {                    List i4flags = findOrCreateTags(flagNames, newTags);                    for (int i = 0; i < i4flags.size(); i++) {                        ImapFlag i4flag = (ImapFlag) i4flags.get(i);                        if (!i4flag.mPermanent)                            sflags |= i4flag.mBitmask;                        else if (Tag.validateId(i4flag.mId))                            tagStr.append(tagStr.length() == 0 ? "" : ",").append(i4flag.mId);                        else if (i4flag.mPositive)                            flagMask |= i4flag.mBitmask;                        else                            flagMask &= ~i4flag.mBitmask;                    }                }                boolean idxAttach = mMailbox.attachmentsIndexingEnabled();                ParsedMessage pm = date != null ? new ParsedMessage(content, date.getTime(), idxAttach) :                                                  new ParsedMessage(content, idxAttach);                try {                    if (!pm.getSender().equals("")) {                        InternetAddress ia = new InternetAddress(pm.getSender());                        if (AccountUtil.addressMatchesAccount(mMailbox.getAccount(), ia.getAddress()))                            flagMask |= Flag.FLAG_FROM_ME;                    }                } catch (Exception e) { }                Message msg = mMailbox.addMessage(getContext(), pm, folder.getId(), false, flagMask, tagStr.toString());                if (msg != null) {                    appendHint.append("[APPENDUID ").append(ImapFolder.getUIDValidity(folder))                              .append(' ').append(msg.getImapUID()).append("] ");                    if (sflags != 0 && mSession.isSelected()) {                        ImapMessage i4msg = mSession.getFolder().getById(msg.getId());                        if (i4msg != null)                            i4msg.setSessionFlags(sflags);                    }                }            }        } catch (ServiceException e) {            deleteTags(newTags);            String msg = "APPEND failed";            if (e.getCode() == MailServiceException.NO_SUCH_FOLDER) {                ZimbraLog.imap.info("APPEND failed: no such folder: " + folderName);                // 6.3.11: "Unless it is certain that the destination mailbox can not be created,                //          the server MUST send the response code "[TRYCREATE]" as the prefix                //          of the text of the tagged NO response."                if (ImapFolder.isPathCreatable('/' + folderName))                    msg = "[TRYCREATE] APPEND failed: no such mailbox";            } else                ZimbraLog.imap.warn("APPEND failed", e);            sendNO(tag, msg);            return canContinue(e);        } catch (IOException e) {            deleteTags(newTags);            ZimbraLog.imap.warn("APPEND failed", e);            sendNO(tag, "APPEND failed");            return CONTINUE_PROCESSING;        } catch (MessagingException e) {            deleteTags(newTags);            // FIXME: shouldn't fail if message parse fails; treat as a blob instead            ZimbraLog.imap.warn("APPEND failed", e);            sendNO(tag, "APPEND failed");            return CONTINUE_PROCESSING;        }        sendNotifications(true, false);        sendOK(tag, appendHint.append("APPEND completed").toString());        return CONTINUE_PROCESSING;    }