int messageId = op.getMessageId();
Message msg = op.getMessage();
    public Element handle(Element request, Map<String, Object> context) throws ServiceException {        ZimbraSoapContext lc = getZimbraSoapContext(context);        Mailbox mbox = getRequestedMailbox(lc);        OperationContext octxt = lc.getOperationContext();        Session session = getSession(context);                Element msgElem = request.getElement(MailService.E_MSG);                String flagsStr = msgElem.getAttribute(MailService.A_FLAGS, null);        String tagsStr = msgElem.getAttribute(MailService.A_TAGS, null);        String folderStr = msgElem.getAttribute(MailService.A_FOLDER);        boolean noICal = msgElem.getAttributeBool(MailService.A_NO_ICAL, false);        long date = msgElem.getAttributeLong(MailService.A_DATE, System.currentTimeMillis());                if (mLog.isDebugEnabled()) {            StringBuffer toPrint = new StringBuffer("<AddMsg ");            if (tagsStr != null)                toPrint.append(" tags=\"").append(tagsStr).append("\"");            if (folderStr != null)                toPrint.append(" folder=\"").append(folderStr).append("\"");            toPrint.append(">");            mLog.debug(toPrint);        }        // sanity-check the supplied tag list        if (tagsStr != null) {            String[] splitTags = tagsStr.split("\\s*,\\s*");            if (splitTags.length > 0)                for (int i = 0; i < splitTags.length; i++) {                    try {                        int tagId = Integer.parseInt(splitTags[i]);                        if (mbox.getTagById(octxt, tagId) == null)                            throw ServiceException.INVALID_REQUEST("Unknown tag: \"" + tagId + "\"", null);                    } catch (NumberFormatException e) {};                }        }        int folderId = -1;        Folder folder = null;        try {            folderId = new ItemId(folderStr, lc).getId();        } catch (ServiceException e) { }        if (folderId > 0) {            folder = mbox.getFolderById(octxt, folderId);        } else {            folder = mbox.getFolderByPath(octxt, folderStr);            folderId = folder.getId();        }        if (mLog.isDebugEnabled())            mLog.debug("folder = " + folder.getName());                // check to see whether the entire message has been uploaded under separate cover        String attachment = msgElem.getAttribute(MailService.A_ATTACHMENT_ID, null);                ParseMimeMessage.MimeMessageData mimeData = new ParseMimeMessage.MimeMessageData();        MimeMessage mm;        if (attachment != null)            mm = SendMsg.parseUploadedMessage(lc, attachment, mimeData);        else            mm = ParseMimeMessage.importMsgSoap(msgElem);                AddMsgOperation op = new AddMsgOperation(session, octxt, mbox, Requester.SOAP, date, tagsStr, folderId, flagsStr, noICal, mm);        op.schedule();        int messageId = op.getMessageId();                // we can now purge the uploaded attachments        if (mimeData.uploads != null)            FileUploadServlet.deleteUploads(mimeData.uploads);                Element response = lc.createElement(MailService.ADD_MSG_RESPONSE);        if (messageId >= 0)            response.addElement(MailService.E_MSG).addAttribute(MailService.A_ID, messageId);                return response;    }