Search in sources :

Example 1 with Body

use of com.zimbra.cs.mailclient.imap.Body in project zm-mailbox by Zimbra.

the class TestImapClient method testAppend.

@Test
public void testAppend() throws Exception {
    login();
    MailboxInfo mb = connection.select("INBOX");
    long exists = mb.getExists();
    Date date = new Date((System.currentTimeMillis() / 1000) * 1000);
    Flags flags = Flags.fromSpec("fs");
    AppendResult res = connection.append("INBOX", Flags.fromSpec("fs"), date, new Literal(Ascii.getBytes(MESSAGE)));
    assertNotNull(res);
    mb = connection.select("INBOX");
    assertEquals(1, mb.getExists() - exists);
    MessageData md = connection.uidFetch(res.getUid(), "(FLAGS BODY.PEEK[] INTERNALDATE)");
    assertNotNull(md);
    assertEquals(date, md.getInternalDate());
    assertEquals(res.getUid(), md.getUid());
    assertEquals(flags, md.getFlags());
    Body[] parts = md.getBodySections();
    assertNotNull(parts);
    assertEquals(1, parts.length);
}
Also used : MessageData(com.zimbra.cs.mailclient.imap.MessageData) Literal(com.zimbra.cs.mailclient.imap.Literal) MailboxInfo(com.zimbra.cs.mailclient.imap.MailboxInfo) AppendResult(com.zimbra.cs.mailclient.imap.AppendResult) Flags(com.zimbra.cs.mailclient.imap.Flags) Body(com.zimbra.cs.mailclient.imap.Body) Date(java.util.Date) Test(org.junit.Test)

Example 2 with Body

use of com.zimbra.cs.mailclient.imap.Body in project zm-mailbox by Zimbra.

the class TestImap method fetchBody.

private byte[] fetchBody(long uid) throws IOException {
    MessageData md = connection.uidFetch(uid, "(BODY.PEEK[])");
    assertNotNull("message not found", md);
    assertEquals(uid, md.getUid());
    Body[] bs = md.getBodySections();
    assertNotNull(bs);
    assertEquals(1, bs.length);
    return bs[0].getImapData().getBytes();
}
Also used : MessageData(com.zimbra.cs.mailclient.imap.MessageData) Body(com.zimbra.cs.mailclient.imap.Body)

Aggregations

Body (com.zimbra.cs.mailclient.imap.Body)2 MessageData (com.zimbra.cs.mailclient.imap.MessageData)2 AppendResult (com.zimbra.cs.mailclient.imap.AppendResult)1 Flags (com.zimbra.cs.mailclient.imap.Flags)1 Literal (com.zimbra.cs.mailclient.imap.Literal)1 MailboxInfo (com.zimbra.cs.mailclient.imap.MailboxInfo)1 Date (java.util.Date)1 Test (org.junit.Test)1