• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IMAPStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: supportsIdle

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
protected boolean supportsIdle(Folder folder) throws MessagingException {
	Store store = folder.getStore();

	if (store instanceof IMAPStore) {
		IMAPStore imapStore = (IMAPStore) store;
		return imapStore.hasCapability("IDLE") && folder instanceof IMAPFolder;
	} else {
		return false;
	}
}
 
开发者ID:camunda,项目名称:camunda-bpm-mail,代码行数:11,代码来源:MailNotificationService.java


示例2: deleteEmail

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
private void deleteEmail(final IMAPStore store, long uid) throws Exception {
	IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX");
	inbox.open(Folder.READ_WRITE);
	javax.mail.Message message = inbox.getMessageByUID(uid);
	if (message != null) {
		Folder trash = store.getFolder(getTrashFolderLocalisedName(inbox));
		trash.open(Folder.READ_WRITE);
		inbox.copyMessages(new javax.mail.Message[] { message }, trash);
		trash.close(true);
	}
	inbox.close(true);
}
 
开发者ID:danielebufarini,项目名称:Reminders,代码行数:13,代码来源:DeleteEmailViaImap.java


示例3: connectToImap

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
/**
  * Connects and authenticates to an IMAP server with OAuth2. You must have
  * called {@code initialize}.
  *
  * @param host Hostname of the imap server, for example {@code
  *     imap.googlemail.com}.
  * @param port Port of the imap server, for example 993.
  * @param userEmail Email address of the user to authenticate, for example
  *     {@code [email protected]}.
  * @param oauthToken The user's OAuth token.
  * @param debug Whether to enable debug logging on the IMAP connection.
  *
  * @return An authenticated IMAPStore that can be used for IMAP operations.
  */
public static IMAPStore connectToImap(String host, int port, String userEmail,
		String oauthToken, boolean debug) throws Exception
{
	Properties props = new Properties();
	props.put("mail.imaps.sasl.enable", "true");
	props.put("mail.imaps.sasl.mechanisms", "XOAUTH2");
	props.put(OAuth2SaslClientFactory.OAUTH_TOKEN_PROP, oauthToken);
	Session session = Session.getInstance(props);
	session.setDebug(debug);

	final URLName unusedUrlName = null;
	IMAPSSLStore store = new IMAPSSLStore(session, unusedUrlName);
	store.connect(host, port, userEmail, EMPTY_PASSWORD);
	
	return store;
}
 
开发者ID:danielebufarini,项目名称:Reminders,代码行数:31,代码来源:OAuth2Authenticator.java


示例4: connectToImap

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
/**
 * Connects and authenticates to an IMAP server with OAuth2. You must have
 * called {@code initialize}.
 *
 * @param host Hostname of the imap server, for example {@code
 *     imap.googlemail.com}.
 * @param port Port of the imap server, for example 993.
 * @param userEmail Email address of the user to authenticate, for example
 *     {@code [email protected]}.
 * @param oauthToken The user's OAuth token.
 * @param debug Whether to enable debug logging on the IMAP connection.
 *
 * @return An authenticated IMAPStore that can be used for IMAP operations.
 */
public static IMAPStore connectToImap(String host,
                                      int port,
                                      String userEmail,
                                      String oauthToken,
                                      boolean debug) throws Exception {
  Properties props = new Properties();
  props.put("mail.imaps.sasl.enable", "true");
  props.put("mail.imaps.sasl.mechanisms", "XOAUTH2");
  props.put(OAuth2SaslClientFactory.OAUTH_TOKEN_PROP, oauthToken);
  Session session = Session.getInstance(props);
  session.setDebug(debug);

  final URLName unusedUrlName = null;
  IMAPSSLStore store = new IMAPSSLStore(session, unusedUrlName);
  final String emptyPassword = "";
  store.connect(host, port, userEmail, emptyPassword);
  return store;
}
 
开发者ID:google,项目名称:gmail-oauth2-tools,代码行数:33,代码来源:OAuth2Authenticator.java


示例5: main

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
/**
 * Authenticates to IMAP with parameters passed in on the commandline.
 */
public static void main(String args[]) throws Exception {
  if (args.length != 2) {
    System.err.println(
        "Usage: OAuth2Authenticator <email> <oauthToken>");
    return;
  }
  String email = args[0];
  String oauthToken = args[1];

  initialize();

  IMAPStore imapStore = connectToImap("imap.gmail.com",
                                      993,
                                      email,
                                      oauthToken,
                                      true);
  System.out.println("Successfully authenticated to IMAP.\n");
  SMTPTransport smtpTransport = connectToSmtp("smtp.gmail.com",
                                              587,
                                              email,
                                              oauthToken,
                                              true);
  System.out.println("Successfully authenticated to SMTP.");
}
 
开发者ID:google,项目名称:gmail-oauth2-tools,代码行数:28,代码来源:OAuth2Authenticator.java


示例6: testQUOTAUnsupported

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test(expected = MockTestException.class)
public void testQUOTAUnsupported() 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 Folder test = defaultFolder.getFolder("test");

    final IMAPStore imapStore = (IMAPStore) store;

    try {
        imapStore.getQuota("");
    } catch (final MessagingException e) {
        throw new MockTestException(e);
    }

}
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:31,代码来源:IMAPTestCase.java


示例7: testSendAndReceiveWithQuotedAddress

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testSendAndReceiveWithQuotedAddress() throws MessagingException, IOException {
    // See https://en.wikipedia.org/wiki/Email_address#Local-part
    String[] toList = {"\"John..Doe\"@localhost",
            "abc.\"defghi\"[email protected]",
            "\"abcdefghixyz\"@localhost",
            "\"Foo Bar\"[email protected]"
    };
    for(String to: toList) {
        greenMail.setUser(to, "pwd");
        InternetAddress[] toAddress = InternetAddress.parse(to);
        String from = to; // Same from and to address for testing correct escaping of both

        final String subject = "testSendAndReceiveWithQuotedAddress";
        final String content = "some body";
        GreenMailUtil.sendTextEmailTest(to, from,
                subject, content);

        assertTrue(greenMail.waitForIncomingEmail(5000, 1));

        final IMAPStore store = greenMail.getImap().createStore();
        store.connect(to, "pwd");
        try {
            IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX");
            folder.open(Folder.READ_ONLY);
            Message[] msgs = folder.getMessages();
            assertTrue(null != msgs && msgs.length == 1);
            final Message msg = msgs[0];
            assertEquals(to, ((InternetAddress)msg.getRecipients(Message.RecipientType.TO)[0]).getAddress());
            assertEquals(from, ((InternetAddress)msg.getFrom()[0]).getAddress());
            assertEquals(subject, msg.getSubject());
            assertEquals(content, msg.getContent().toString());
            assertArrayEquals(toAddress, msg.getRecipients(Message.RecipientType.TO));
        } finally {
            store.close();
        }
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:39,代码来源:SenderRecipientTest.java


示例8: testQuotaCapability

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testQuotaCapability() throws MessagingException {
    greenMail.setUser("[email protected]", "pwd");
    greenMail.setQuotaSupported(false);
    final IMAPStore store = greenMail.getImap().createStore();
    try {
        store.connect("[email protected]", "pwd");

        Quota testQuota = new Quota("INBOX");
        testQuota.setResourceLimit("STORAGE", 1024L * 42L);
        testQuota.setResourceLimit("MESSAGES", 5L);
        store.setQuota(testQuota);
        fail("Excepted MessageException since quota capability is turned off");
    } catch (MessagingException ex) {
        assertEquals(ex.getMessage(), "QUOTA not supported");
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:20,代码来源:ImapServerTest.java


示例9: populateFromStore

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
/**
 * Static method to populate a {@link StoreIndex} with the messages in an {@link IMAPStore}
 *
 * @param index
 * @param store
 * @param threads
 * @return
 * @throws MessagingException
 * @throws InterruptedException
 */
public static final StoreIndex populateFromStore(final StoreIndex index, IMAPStore store,
        int threads) throws MessagingException, InterruptedException {
    MessagingException messagingException = null;
    //Crawl
    synchronized (index.getFolders()) {
        final ExecutorService service = Executors.newFixedThreadPool(threads);
        try {
            crawlFolders(store, index, store.getDefaultFolder(), service);
        } catch (MessagingException ex) {
            messagingException = ex;
        }
        service.shutdown();
        service.awaitTermination(1, TimeUnit.HOURS);
        if (index.hasCrawlException()) {
            messagingException = index.getCrawlExceptions().get(0);
        }
    }
    if (messagingException != null) {
        throw messagingException;
    }
    return index;
}
 
开发者ID:manusa,项目名称:mnIMAPSync,代码行数:33,代码来源:StoreIndex.java


示例10: hasSortCapability

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
/**
 * Check whether the email store has the sort capability or not.
 *
 * @param store Email store
 * @return true if the store is an IMAP store and it has the store capability
 * @throws MessagingException In case capability check fails
 */
private static boolean hasSortCapability(Store store) throws MessagingException {
    if (store instanceof IMAPStore) {
        IMAPStore imapStore = (IMAPStore) store;
        if (imapStore.hasCapability("SORT*")) {
            return true;
        }
    }
    return false;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:MailConsumer.java


示例11: getInbox

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
private IMAPFolder getInbox(IMAPStore store) throws MessagingException {
	IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX");
	inbox.open(Folder.READ_WRITE);
	return inbox;
}
 
开发者ID:danielebufarini,项目名称:Reminders,代码行数:6,代码来源:GMailImapReader.java


示例12: connect

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
private boolean connect(String protocol, String host, String port, String userName, String password) {
	Properties properties = getServerProperties(protocol, host, port);
	Session session = Session.getDefaultInstance(properties);
	try {
		store = (IMAPStore)session.getStore(protocol);
		store.connect(userName, password);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:mathieulegoc,项目名称:SmartTokens,代码行数:13,代码来源:GmailReader.java


示例13: connect

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
public boolean connect(String protocol, String host, String port, String userName, String password) {
	Properties properties = getServerProperties(protocol, host, port);
	Session session = Session.getDefaultInstance(properties);

	try {
		store = (IMAPStore)session.getStore(protocol);
		store.connect(userName, password);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:mathieulegoc,项目名称:SmartTokens,代码行数:14,代码来源:MailBean.java


示例14: testSendAndReceive

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testSendAndReceive() throws UnsupportedEncodingException, MessagingException, UserException {
    Session smtpSession = greenMail.getSmtp().createSession();

    Message msg = new MimeMessage(smtpSession);
    msg.setFrom(new InternetAddress("[email protected]"));
    msg.addRecipient(Message.RecipientType.TO,
            new InternetAddress("[email protected]"));
    msg.setSubject("Email sent to GreenMail via plain JavaMail");
    msg.setText("Fetch me via IMAP");
    Transport.send(msg);

    // Create user, as connect verifies pwd
    greenMail.setUser("[email protected]", "[email protected]", "secret-pwd");

    // Alternative 1: Create session and store or ...
    Session imapSession = greenMail.getImap().createSession();
    Store store = imapSession.getStore("imap");
    store.connect("[email protected]", "secret-pwd");
    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message msgReceived = inbox.getMessage(1);
    assertEquals(msg.getSubject(), msgReceived.getSubject());

    // Alternative 2: ... let GreenMail create and configure a store:
    IMAPStore imapStore = greenMail.getImap().createStore();
    imapStore.connect("[email protected]", "secret-pwd");
    inbox = imapStore.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    msgReceived = inbox.getMessage(1);
    assertEquals(msg.getSubject(), msgReceived.getSubject());

    // Alternative 3: ... directly fetch sent message using GreenMail API
    assertEquals(1, greenMail.getReceivedMessagesForDomain("[email protected]").length);
    msgReceived = greenMail.getReceivedMessagesForDomain("[email protected]")[0];
    assertEquals(msg.getSubject(), msgReceived.getSubject());

    store.close();
    imapStore.close();
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:41,代码来源:ExampleJavaMailTest.java


示例15: testRenameINBOXFolder

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
/**
 * 
 * https://tools.ietf.org/html/rfc3501#page-37 :
 * <q>
 *     Renaming INBOX is permitted, and has special behavior.  It moves
 *     all messages in INBOX to a new mailbox with the given name,
 *     leaving INBOX empty.  If the server implementation supports
 *     inferior hierarchical names of INBOX, these are unaffected by a
 *     rename of INBOX.
 *  </q>
 *
 * @throws MessagingException
 * @throws InterruptedException
 */
@Test
public void testRenameINBOXFolder() throws MessagingException, InterruptedException {
    greenMail.setUser("[email protected]", "pwd");
    GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "Test subject",
            "Test message", greenMail.getSmtp().getServerSetup());

    final IMAPStore store = greenMail.getImap().createStore();
    store.connect("[email protected]", "pwd");
    try {

        // Create some folders
        Folder inboxFolder = store.getFolder("INBOX");
        assertTrue(inboxFolder.exists());
        inboxFolder.open(Folder.READ_ONLY);
        assertEquals(1, inboxFolder.getMessages().length);

        Folder inboxRenamedFolder = store.getFolder("INBOX-renamed");
        assertFalse(inboxRenamedFolder.exists());

        inboxFolder.close(true);
        inboxFolder.renameTo(inboxRenamedFolder);
        assertTrue(inboxRenamedFolder.exists());
        inboxRenamedFolder.open(Folder.READ_ONLY);
        assertEquals(1, inboxRenamedFolder.getMessages().length);

        inboxFolder = store.getFolder("INBOX");
        assertTrue(inboxFolder.exists());
        inboxFolder.open(Folder.READ_ONLY);
        assertEquals(0, inboxFolder.getMessages().length);
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:48,代码来源:ImapServerTest.java


示例16: testFolderRequiringEscaping

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testFolderRequiringEscaping() throws MessagingException {
    greenMail.setUser("[email protected]", "pwd");
    GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "test subject", "", greenMail.getSmtp().getServerSetup());

    final IMAPStore store = greenMail.getImap().createStore();
    store.connect("[email protected]", "pwd");
    try {

        // Create some folders
        Folder inboxFolder = store.getFolder("INBOX");
        inboxFolder.open(Folder.READ_ONLY);

        final Folder folderRequiringEscaping = inboxFolder.getFolder("requires escaping Ä");
        assertTrue(folderRequiringEscaping.create(Folder.HOLDS_FOLDERS | Folder.HOLDS_MESSAGES));
        folderRequiringEscaping.open(Folder.READ_WRITE);

        assertEquals(0, folderRequiringEscaping.getMessageCount());
        assertEquals(1, inboxFolder.getMessageCount());

        inboxFolder.copyMessages(inboxFolder.getMessages(), folderRequiringEscaping);

        folderRequiringEscaping.expunge(); // invalidates folder cache
        assertEquals(1, folderRequiringEscaping.getMessageCount());
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:29,代码来源:ImapServerTest.java


示例17: testUIDExpunge

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testUIDExpunge() throws MessagingException {
    greenMail.setUser("[email protected]", "pwd");

    // Create some test emails
    int numberOfEmails = 10;
    long[] uids = new long[numberOfEmails];
    for (int i = 0; i < numberOfEmails; i++) {
        GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "Test UID expunge #" + i,
                "Test message", greenMail.getSmtp().getServerSetup());
    }

    final IMAPStore store = greenMail.getImap().createStore();
    store.connect("[email protected]", "pwd");
    try {
        IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX");
        folder.open(Folder.READ_WRITE);

        Message[] messages = folder.getMessages();
        assertEquals(numberOfEmails, messages.length);

        // Mark even as deleted ...
        Message[] msgsForDeletion = new Message[uids.length / 2];
        for (int i = 0; i < messages.length; i++) {
            assertFalse(messages[i].getFlags().contains(Flags.Flag.DELETED));
            uids[i] = folder.getUID(messages[i]);
            if (i % 2 == 0) { // Deleted
                messages[i].setFlag(Flags.Flag.DELETED, true);
                msgsForDeletion[i / 2] = messages[i];
            }
        }

        // ... and expunge (with UID)
        folder.expunge(msgsForDeletion);

        // Check
        for (int i = 0; i < uids.length; i++) {
            final Message message = folder.getMessageByUID(uids[i]);
            if (i % 2 == 0) { // Deleted
                assertNull(message);
            } else {
                assertTrue("" + i, !message.isExpunged());
                assertTrue("" + i, !message.getFlags().contains(Flags.Flag.DELETED));
            }
        }
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:50,代码来源:ImapServerTest.java


示例18: testAppend

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testAppend() throws MessagingException {
    greenMail.setUser("[email protected]", "pwd");

    GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "Test Append",
            "Test message", greenMail.getSmtp().getServerSetup());

    final IMAPStore store = greenMail.getImap().createStore();
    store.connect("[email protected]", "pwd");
    try {
        IMAPFolder inboxFolder = (IMAPFolder) store.getFolder("INBOX");
        inboxFolder.open(Folder.READ_WRITE);

        Message[] messages = inboxFolder.getMessages();
        assertEquals(1, messages.length);
        Message message = messages[0];

        Message[] toBeAppended = new Message[]{
                new MimeMessage((MimeMessage) message) // Copy
        };
        toBeAppended[0].setSubject("testAppend#1");

        inboxFolder.appendMessages(toBeAppended);
        messages = inboxFolder.getMessages();
        assertEquals(2, messages.length);

        // UIDPLUS
        toBeAppended[0] = new MimeMessage((MimeMessage) message);
        toBeAppended[0].setSubject("testAppend#2");

        final AppendUID[] appendUIDs = inboxFolder.appendUIDMessages(toBeAppended); // Copy again
        long uid = appendUIDs[0].uid;
        Message newMsg = inboxFolder.getMessageByUID(uid);
        assertEquals(toBeAppended[0].getSubject(), newMsg.getSubject());
        assertTrue(appendUIDs[0].uidvalidity == inboxFolder.getUIDValidity());
        messages = inboxFolder.getMessages();
        assertEquals(3, messages.length);
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:42,代码来源:ImapServerTest.java


示例19: testExpunge

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
@Test
public void testExpunge() throws MessagingException {
    greenMail.setUser("[email protected]", "pwd");

    for (int i = 0; i < 6; i++) {
        GreenMailUtil.sendTextEmail("[email protected]", "[email protected]", "Test subject #" + i,
                "Test message", ServerSetupTest.SMTP);
    }
    final IMAPStore store = greenMail.getImap().createStore();
    store.connect("[email protected]", "pwd");
    try {
        Folder inboxFolder = store.getFolder("INBOX");
        inboxFolder.open(Folder.READ_WRITE);

        Message[] messages = inboxFolder.getMessages();
        assertEquals(6, messages.length);
        inboxFolder.setFlags(new int[]{2, 3}, new Flags(DELETED), true); // 1 and 2, offset is not zero-based

        assertEquals(false, inboxFolder.getMessage(1).isSet(DELETED));
        assertEquals(true, inboxFolder.getMessage(2).isSet(DELETED));
        assertEquals(true, inboxFolder.getMessage(3).isSet(DELETED));
        assertEquals(false, inboxFolder.getMessage(4).isSet(DELETED));
        assertEquals(false, inboxFolder.getMessage(5).isSet(DELETED));
        assertEquals(false, inboxFolder.getMessage(6).isSet(DELETED));
        assertEquals(2, inboxFolder.getDeletedMessageCount());
        Message[] expunged = inboxFolder.expunge();
        assertEquals(2, expunged.length);

        messages = inboxFolder.getMessages();
        assertEquals(4, messages.length);
        assertEquals("Test subject #0", messages[0].getSubject());
        assertEquals("Test subject #3", messages[1].getSubject());
        assertEquals("Test subject #4", messages[2].getSubject());
        assertEquals("Test subject #5", messages[3].getSubject());
    } finally {
        store.close();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:39,代码来源:ImapServerTest.java


示例20: crawlFolders

import com.sun.mail.imap.IMAPStore; //导入依赖的package包/类
private static StoreIndex crawlFolders(IMAPStore store, StoreIndex storeIndex, Folder folder,
        ExecutorService service) throws MessagingException {
    if (folder != null) {
        final String folderName = folder.getFullName();
        storeIndex.getFolders().add(folderName);
        if ((folder.getType() & Folder.HOLDS_MESSAGES) == Folder.HOLDS_MESSAGES) {
            folder.open(Folder.READ_ONLY);
            if (folder.getMode() != Folder.READ_ONLY) {
                folder.expunge();
            }
            final int messageCount = folder.getMessageCount();
            folder.close(false);
            int pos = 1;
            while (pos + MNIMAPSync.BATCH_SIZE <= messageCount) {
                service.execute(new FolderCrawler(store, folderName, pos,
                        pos + MNIMAPSync.BATCH_SIZE, storeIndex));
                pos = pos + MNIMAPSync.BATCH_SIZE;
            }
            service.execute(new FolderCrawler(store, folderName, pos, messageCount, storeIndex));
        }
        //Folder recursion. Get all children
        if ((folder.getType() & Folder.HOLDS_FOLDERS) == Folder.HOLDS_FOLDERS) {
            for (Folder child : folder.list()) {
                crawlFolders(store, storeIndex, child, service);
            }
        }
    }
    return storeIndex;
}
 
开发者ID:manusa,项目名称:mnIMAPSync,代码行数:30,代码来源:StoreIndex.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BorderLayout类代码示例发布时间:2022-05-22
下一篇:
Java PersistentLongFile类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap