attach.addElement(MailService.E_MIMEPART).addAttribute(MailService.A_ID, part.getMessageId()).addAttribute(MailService.A_PART, part.getPartName());
attach.addElement(MailService.E_MIMEPART).addAttribute(MailService.A_MESSAGE_ID, part.getMessageId()).addAttribute(MailService.A_PART, part.getPartName());
    public ZSendMessageResponse sendMessage(List<ZEmailAddress> addrs, String subject, String origMessageIdHeader,             String contentType, String content, String attachmentUploadId,             List<String> messageIdsToAttach, List<ZSendMessagePart> messagePartsToAttach, List<String> contactIdsToAttach) throws ServiceException {        XMLElement req = new XMLElement(MailService.SEND_MSG_REQUEST);        Element m = req.addElement(MailService.E_MSG);        for (ZEmailAddress addr : addrs) {            Element e = m.addElement(MailService.E_EMAIL);            e.addAttribute(MailService.A_TYPE, addr.getType());            e.addAttribute(MailService.A_ADDRESS, addr.getAddress());            e.addAttribute(MailService.A_PERSONAL, addr.getPersonal());        }        if (subject != null) m.addElement(MailService.E_SUBJECT).setText(subject);        if (origMessageIdHeader != null) m.addElement(MailService.E_IN_REPLY_TO).setText(origMessageIdHeader);        Element mp = m.addElement(MailService.E_MIMEPART);        mp.addAttribute(MailService.A_CONTENT_TYPE, contentType);        mp.addElement(MailService.E_CONTENT).setText(content);        if (attachmentUploadId != null || messageIdsToAttach != null || messagePartsToAttach != null || contactIdsToAttach != null) {            Element attach = m.addElement(MailService.E_ATTACH);            if (attachmentUploadId != null)                attach.addAttribute(MailService.A_ATTACHMENT_ID, attachmentUploadId);            if (messageIdsToAttach != null) {                for (String mid: messageIdsToAttach) {                    attach.addElement(MailService.E_MSG).addAttribute(MailService.A_ID, mid);                }            }            if (messagePartsToAttach != null) {                for (ZSendMessagePart part: messagePartsToAttach) {                    attach.addElement(MailService.E_MIMEPART).addAttribute(MailService.A_ID, part.getMessageId()).addAttribute(MailService.A_PART, part.getPartName());                    }            }        }        Element resp = invoke(req);        Element msg = resp.getOptionalElement(MailService.E_MSG);        String id = msg == null ? null : msg.getAttribute(MailService.A_ID, null);        return new ZSendMessageResponse(id);    }