Search in sources :

Example 16 with ZOutgoingMessage

use of com.zimbra.client.ZMailbox.ZOutgoingMessage in project zm-mailbox by Zimbra.

the class TestLmtp method testAttachedMessage.

/**
     * Sends a message with another message attached and confirms that the subject
     * of the attached message is indexed.
     * @see MessageRFC822Handler
     */
@Test
public void testAttachedMessage() throws Exception {
    String outerSubject = NAME_PREFIX + " testAttachedMessage outer";
    String innerSubject = NAME_PREFIX + " testAttachedMessage inner";
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    // Assemble outer message
    ZOutgoingMessage msg = new ZOutgoingMessage();
    List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
    addresses.add(new ZEmailAddress(TestUtil.getAddress(USER_NAME), null, null, ZEmailAddress.EMAIL_TYPE_TO));
    msg.setAddresses(addresses);
    msg.setSubject(outerSubject);
    // Assemble body and inner message
    String attachedMessageString = TestUtil.getTestMessage(innerSubject, USER_NAME, USER_NAME, null);
    MessagePart attachedMessage = new MessagePart("message/rfc822", attachedMessageString);
    MessagePart body = new MessagePart("text/plain", "This is the outer message");
    msg.setMessagePart(new MessagePart("multipart/mixed", body, attachedMessage));
    // Send and wait for it to arrive
    mbox.sendMessage(msg, null, false);
    TestUtil.waitForMessage(mbox, "in:inbox " + outerSubject);
    // Test search for message subject
    List<ZMessage> msgs = TestUtil.search(mbox, "in:inbox " + innerSubject);
    Assert.assertEquals(1, msgs.size());
    msgs = TestUtil.search(mbox, "in:sent " + innerSubject);
    Assert.assertEquals(1, msgs.size());
    // Test search for message body
    msgs = TestUtil.search(mbox, "in:inbox " + NAME_PREFIX + " waves");
    Assert.assertEquals(1, msgs.size());
    msgs = TestUtil.search(mbox, "in:sent " + NAME_PREFIX + " waves");
    Assert.assertEquals(1, msgs.size());
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZMailbox(com.zimbra.client.ZMailbox) ZEmailAddress(com.zimbra.client.ZEmailAddress) MessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with ZOutgoingMessage

use of com.zimbra.client.ZMailbox.ZOutgoingMessage in project zm-mailbox by Zimbra.

the class TestUtil method createAppointment.

public static ZAppointmentResult createAppointment(ZMailbox mailbox, String subject, String attendee, Date startDate, Date endDate) throws ServiceException {
    ZInvite invite = new ZInvite();
    ZInvite.ZComponent comp = new ZComponent();
    comp.setStatus(ZStatus.CONF);
    comp.setClassProp(ZClass.PUB);
    comp.setTransparency(ZTransparency.O);
    comp.setStart(new ZDateTime(startDate.getTime(), false, mailbox.getPrefs().getTimeZone()));
    comp.setEnd(new ZDateTime(endDate.getTime(), false, mailbox.getPrefs().getTimeZone()));
    comp.setName(subject);
    comp.setOrganizer(new ZOrganizer(mailbox.getName()));
    if (attendee != null) {
        attendee = addDomainIfNecessary(attendee);
        ZAttendee zattendee = new ZAttendee();
        zattendee.setAddress(attendee);
        zattendee.setRole(ZRole.REQ);
        zattendee.setParticipantStatus(ZParticipantStatus.NE);
        zattendee.setRSVP(true);
        comp.getAttendees().add(zattendee);
    }
    invite.getComponents().add(comp);
    ZOutgoingMessage m = null;
    if (attendee != null) {
        m = getOutgoingMessage(attendee, subject, "Test appointment", null);
    }
    return mailbox.createAppointment(ZFolder.ID_CALENDAR, null, m, invite, null);
}
Also used : ZComponent(com.zimbra.client.ZInvite.ZComponent) ZDateTime(com.zimbra.client.ZDateTime) ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZInvite(com.zimbra.client.ZInvite) ZAttendee(com.zimbra.client.ZInvite.ZAttendee) ZOrganizer(com.zimbra.client.ZInvite.ZOrganizer) ZComponent(com.zimbra.client.ZInvite.ZComponent)

Example 18 with ZOutgoingMessage

use of com.zimbra.client.ZMailbox.ZOutgoingMessage in project zm-mailbox by Zimbra.

the class TestUtil method saveDraftAndSendMessage.

public static void saveDraftAndSendMessage(ZMailbox senderMbox, String recipient, String subject, String body, String attachmentUploadId) throws ServiceException {
    ZOutgoingMessage outgoingDraft = getOutgoingMessage(recipient, subject, body, attachmentUploadId);
    ZMessage draft = senderMbox.saveDraft(outgoingDraft, null, Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
    ZOutgoingMessage outgoing = getOutgoingMessage(recipient, subject, body, null);
    if (attachmentUploadId != null) {
        AttachedMessagePart part = new AttachedMessagePart(draft.getId(), "2", null);
        outgoing.setMessagePartsToAttach(Arrays.asList(part));
    }
    senderMbox.sendMessage(outgoing, null, false);
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) AttachedMessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart)

Example 19 with ZOutgoingMessage

use of com.zimbra.client.ZMailbox.ZOutgoingMessage in project zm-mailbox by Zimbra.

the class TestUtil method getOutgoingMessage.

public static ZOutgoingMessage getOutgoingMessage(String recipient, String subject, String body, String attachmentUploadId) throws ServiceException {
    ZOutgoingMessage msg = new ZOutgoingMessage();
    List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
    addresses.add(new ZEmailAddress(addDomainIfNecessary(recipient), null, null, ZEmailAddress.EMAIL_TYPE_TO));
    msg.setAddresses(addresses);
    msg.setSubject(subject);
    msg.setMessagePart(new MessagePart("text/plain", body));
    msg.setAttachmentUploadId(attachmentUploadId);
    return msg;
}
Also used : ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZEmailAddress(com.zimbra.client.ZEmailAddress) AttachedMessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart) MessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart) ArrayList(java.util.ArrayList)

Aggregations

ZOutgoingMessage (com.zimbra.client.ZMailbox.ZOutgoingMessage)19 ZMessage (com.zimbra.client.ZMessage)12 Test (org.junit.Test)10 ZEmailAddress (com.zimbra.client.ZEmailAddress)9 ZMailbox (com.zimbra.client.ZMailbox)8 MessagePart (com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart)8 ArrayList (java.util.ArrayList)8 AttachedMessagePart (com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart)5 ZInvite (com.zimbra.client.ZInvite)2 ZComponent (com.zimbra.client.ZInvite.ZComponent)2 ZOrganizer (com.zimbra.client.ZInvite.ZOrganizer)2 ZMimePart (com.zimbra.client.ZMessage.ZMimePart)2 BeforeClass (org.junit.BeforeClass)2 ZDateTime (com.zimbra.client.ZDateTime)1 ZIdentity (com.zimbra.client.ZIdentity)1 ZAttendee (com.zimbra.client.ZInvite.ZAttendee)1 ZAppointmentResult (com.zimbra.client.ZMailbox.ZAppointmentResult)1 ZSendMessageResponse (com.zimbra.client.ZMailbox.ZSendMessageResponse)1 ServiceException (com.zimbra.common.service.ServiceException)1 Element (com.zimbra.common.soap.Element)1