当前位置: 首页>>代码示例>>Java>>正文


Java POP3Folder类代码示例

本文整理汇总了Java中com.sun.mail.pop3.POP3Folder的典型用法代码示例。如果您正苦于以下问题:Java POP3Folder类的具体用法?Java POP3Folder怎么用?Java POP3Folder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


POP3Folder类属于com.sun.mail.pop3包,在下文中一共展示了POP3Folder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddMessages

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
@Test
public void testAddMessages() 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

    final Store store = session.getStore();
    store.connect("[email protected]", null);
    final Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Assert.assertEquals(3, inbox.getMessageCount());
    Assert.assertNotNull(inbox.getMessage(1));

    inbox.close(true);

    Assert.assertEquals(3, inbox.getMessageCount());

    inbox.open(Folder.READ_ONLY);
    inbox.getMessage(1).setFlag(Flag.DELETED, true);

    inbox.close(true);
    inbox.open(Folder.READ_ONLY);
    Assert.assertEquals(2, inbox.getMessageCount());
    Assert.assertTrue(inbox instanceof POP3Folder);
    Assert.assertEquals("12", ((POP3Folder) inbox).getUID(inbox.getMessage(1)));
    inbox.close(true);
}
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:37,代码来源:POP3TestCase.java

示例2: testRetrieve

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
@Test
public void testRetrieve() throws Exception {
    assertNotNull(greenMail.getPop3());
    final String subject = GreenMailUtil.random();
    final String body = GreenMailUtil.random() + "\r\n" + GreenMailUtil.random() + "\r\n" + GreenMailUtil.random();
    String to = "[email protected]";
    GreenMailUtil.sendTextEmailTest(to, "[email protected]", subject, body);
    greenMail.waitForIncomingEmail(5000, 1);

    try (Retriever retriever = new Retriever(greenMail.getPop3())) {
        Message[] messages = retriever.getMessages(to);
        assertEquals(1, messages.length);
        assertEquals(subject, messages[0].getSubject());
        assertEquals(body, GreenMailUtil.getBody(messages[0]).trim());

        // UID
        POP3Folder f = (POP3Folder) messages[0].getFolder();
        assertNotEquals("UNKNOWN", f.getUID(messages[0]));
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:21,代码来源:Pop3ServerTest.java

示例3: testDefaultFolder

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
@Test
public void testDefaultFolder() 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_pop3");
    store.connect("[email protected]", null);
    final Folder defaultFolder = store.getDefaultFolder();
    final Folder inbox = defaultFolder.getFolder("INBOX");

    inbox.open(Folder.READ_WRITE);

    Assert.assertEquals("[INBOX]", Arrays.toString(defaultFolder.list()));

    Assert.assertEquals(3, inbox.getMessageCount());
    Assert.assertNotNull(inbox.getMessage(1));

    inbox.close(true);

    Assert.assertEquals(3, inbox.getMessageCount());

    inbox.open(Folder.READ_ONLY);
    inbox.getMessage(1).setFlag(Flag.DELETED, true);

    inbox.close(true);
    inbox.open(Folder.READ_WRITE);
    Assert.assertEquals(2, inbox.getMessageCount());
    Assert.assertTrue(inbox instanceof POP3Folder);
    Assert.assertEquals("12", ((POP3Folder) inbox).getUID(inbox.getMessage(1)));
    inbox.close(true);
}
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:43,代码来源:POP3TestCase.java

示例4: getMessageId

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
@Override
public String getMessageId(Folder folder, Message message)
		throws MessagingException {
	if (!(folder instanceof POP3Folder))
		return null;
	return ((POP3Message) message).getMessageID();
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:8,代码来源:POP3Crawler.java

示例5: serverList

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
/**
 * List server mails
 */
private void serverList(String userId, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException,
		DatabaseException, MessagingException {
	log.debug("serverList({}, {}, {})", new Object[]{userId, request, response});
	int maId = WebUtils.getInt(request, "ma_id");
	String ma_user = WebUtils.getString(request, "ma_user");
	int start = WebUtils.getInt(request, "start", 1);
	Session session = Session.getDefaultInstance(MailUtils.getProperties());
	List<Map<String, Object>> serverMails = new ArrayList<Map<String, Object>>();

	// Open connection
	MailAccount ma = MailAccountDAO.findByPk(maId);
	Store store = session.getStore(ma.getMailProtocol());
	store.connect(ma.getMailHost(), ma.getMailUser(), ma.getMailPassword());
	Folder folder = store.getFolder(ma.getMailFolder());
	folder.open(Folder.READ_ONLY);
	int max = folder.getMessageCount();

	// Get messages
	int end = start + PAGINATION_LIMIT - 1;
	Message[] messages = folder.getMessages(start, end < max ? end : max);
	FetchProfile fp = new FetchProfile();
	fp.add(FetchProfile.Item.CONTENT_INFO);
	fp.add(FetchProfile.Item.ENVELOPE);
	fp.add(FetchProfile.Item.FLAGS);
	folder.fetch(messages, fp);

	// Read mails
	for (Message msg : messages) {
		Map<String, Object> mail = new HashMap<String, Object>();
		mail.put("receivedDate", msg.getReceivedDate());
		mail.put("sentDate", msg.getSentDate());
		mail.put("subject", (msg.getSubject() == null || msg.getSubject().isEmpty()) ? MailUtils.NO_SUBJECT : msg.getSubject());
		mail.put("from", msg.getFrom().length > 0 ? MailUtils.addressToString(msg.getFrom()[0]) : "");
		mail.put("seen", msg.isSet(Flags.Flag.SEEN));
		mail.put("msgNumber", msg.getMessageNumber());

		if (folder instanceof POP3Folder) {
			mail.put("uid", msg.getMessageNumber());
		} else if (folder instanceof IMAPFolder) {
			mail.put("uid", ((IMAPFolder) folder).getUID(msg));
		}

		serverMails.add(mail);
	}

	// Close connection
	folder.close(false);
	store.close();

	ServletContext sc = getServletContext();
	sc.setAttribute("ma_id", maId);
	sc.setAttribute("ma_user", ma_user);
	sc.setAttribute("max", max);
	sc.setAttribute("start", start);
	sc.setAttribute("limit", PAGINATION_LIMIT);
	sc.setAttribute("serverMails", serverMails);
	sc.getRequestDispatcher("/admin/mail_server_list.jsp").forward(request, response);
	log.debug("serverList: void");
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:63,代码来源:MailAccountServlet.java

示例6: getId

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
protected String getId(Folder folder,Message message) throws MessagingException {
	return ((POP3Folder)folder).getUID(message);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:4,代码来源:PopClient.java

示例7: _getId

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
@Override
protected String _getId(Folder folder,Message message) throws MessagingException {
	
	return ((POP3Folder)folder).getUID(message);
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:6,代码来源:PopClient.java

示例8: onMessageDeletes

import com.sun.mail.pop3.POP3Folder; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void onMessageDeletes(final Set msgs, final Folder folder) throws IOException, MessagingException {

    if (msgs.size() == 0) {
        return;
    }

    createIndexIfNotExists();
    
    client.admin().indices().refresh(new RefreshRequest()).actionGet();

    logger.info("Will delete " + msgs.size() + " messages locally for folder " + folder.getURLName().toString());

    final BoolQueryBuilder query = new BoolQueryBuilder();

    if (folder instanceof POP3Folder) {
        query.must(QueryBuilders.termsQuery("popId", msgs));
    } else {
        query.must(QueryBuilders.termsQuery("uid", msgs));
    }

    query.must(QueryBuilders.termQuery("folderUri", folder.getURLName().toString()));

    DeleteByQuery.deleteByQuery(client, index, new String[]{type}, query);

}
 
开发者ID:salyh,项目名称:elasticsearch-imap,代码行数:28,代码来源:ElasticsearchMailDestination.java


注:本文中的com.sun.mail.pop3.POP3Folder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。