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());
}
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);
}
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);
}
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;
}
Aggregations