本文整理汇总了Java中com.sun.mail.imap.IMAPFolder.addMessages方法的典型用法代码示例。如果您正苦于以下问题:Java IMAPFolder.addMessages方法的具体用法?Java IMAPFolder.addMessages怎么用?Java IMAPFolder.addMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.mail.imap.IMAPFolder
的用法示例。
在下文中一共展示了IMAPFolder.addMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.sun.mail.imap.IMAPFolder; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
final Session session = Session.getInstance(getProperties());
final MockMailbox mb = MockMailbox.get("[email protected]");
final MailboxFolder mf = mb.getInbox();
final MimeMessage msg = new MimeMessage((Session) null);
msg.setSubject("Test");
msg.setFrom("[email protected]");
msg.setText("Some text here ...");
msg.setRecipient(RecipientType.TO, new InternetAddress("[email protected]"));
mf.add(msg); // 11
mf.add(msg); // 12
mf.add(msg); // 13
mb.getRoot().getOrAddSubFolder("test").create().add(msg);
final Store store = session.getStore("mock_imap");
store.connect("[email protected]", null);
final Folder defaultFolder = store.getDefaultFolder();
final IMAPFolder test = (IMAPFolder) defaultFolder.getFolder("test");
final IdleMessageCountListener mcl = new IdleMessageCountListener();
test.addMessageCountListener(mcl);
test.open(Folder.READ_WRITE);
final IdleThread it = new IdleThread(test);
it.start();
final IdleThread it2 = new IdleThread(test);
it2.start();
test.addMessages(new Message[] { msg });
test.addMessages(new Message[] { msg });
test.addMessages(new Message[] { msg });
// test.close(true);
System.out.println(it.getException());
System.out.println(mcl.getAddedCount());
System.out.println(mcl.getRemovedCount());
System.out.println(test.getMessageCount());
System.out.println(it.getIdleCount());
// System.exit(1);
}
示例2: testIDLESupported
import com.sun.mail.imap.IMAPFolder; //导入方法依赖的package包/类
@Test
public void testIDLESupported() throws Exception {
final MockMailbox mb = MockMailbox.get("[email protected]");
final MailboxFolder mf = mb.getInbox();
final MimeMessage msg = new MimeMessage((Session) null);
msg.setSubject("Test");
msg.setFrom("[email protected]");
msg.setText("Some text here ...");
msg.setRecipient(RecipientType.TO, new InternetAddress("[email protected]"));
mf.add(msg); // 11
mf.add(msg); // 12
mf.add(msg); // 13
mb.getRoot().getOrAddSubFolder("test").create().add(msg);
final Store store = session.getStore("mock_imap");
store.connect("[email protected]", null);
final Folder defaultFolder = store.getDefaultFolder();
final IMAPFolder test = (IMAPFolder) defaultFolder.getFolder("test");
final IdleMessageCountListener mcl = new IdleMessageCountListener();
test.addMessageCountListener(mcl);
test.open(Folder.READ_WRITE);
final IdleThread it = new IdleThread(test);
it.start();
test.addMessages(new Message[] { msg });
test.addMessages(new Message[] { msg });
test.addMessages(new Message[] { msg });
Thread.sleep(500);
it.interrupt();
it.join();
test.close(true);
Assert.assertNull(it.getException());
Assert.assertEquals(3, mcl.getAddedCount());
Assert.assertEquals(0, mcl.getRemovedCount());
Assert.assertEquals(4, test.getMessageCount());
}