List of usage examples for javax.mail.event ConnectionEvent CLOSED
int CLOSED
To view the source code for javax.mail.event ConnectionEvent CLOSED.
Click Source Link
From source file:com.sun.mail.pop3.POP3Folder.java
public synchronized void close(boolean expunge) throws MessagingException { checkOpen();//from w w w . j av a2 s . c o m try { /* * Some POP3 servers will mark messages for deletion when * they're read. To prevent such messages from being * deleted before the client deletes them, you can set * the mail.pop3.rsetbeforequit property to true. This * causes us to issue a POP3 RSET command to clear all * the "marked for deletion" flags. We can then explicitly * delete messages as desired. */ if (((POP3Store) store).rsetBeforeQuit) port.rset(); if (expunge && mode == READ_WRITE) { // find all messages marked deleted and issue DELE commands POP3Message m; for (int i = 0; i < message_cache.size(); i++) { if ((m = (POP3Message) message_cache.elementAt(i)) != null) { if (m.isSet(Flags.Flag.DELETED)) try { port.dele(i + 1); } catch (IOException ioex) { throw new MessagingException("Exception deleting messages during close", ioex); } } } } port.quit(); } catch (IOException ex) { // do nothing } finally { port = null; ((POP3Store) store).closePort(this); message_cache = null; opened = false; notifyConnectionListeners(ConnectionEvent.CLOSED); } }
From source file:org.sourceforge.net.javamail4ews.store.EwsFolder.java
@Override public void close(boolean expunge) throws MessagingException { if (mode == javax.mail.Folder.READ_WRITE) { try {/*from ww w .j a v a 2s .com*/ if (expunge) { expunge(); } // Update the messages markMessageRead(messages); markMessageRead(unreadMessages); // and the folder itself folder.update(); } catch (Exception e) { // Close anyway throw new MessagingException(e.getMessage(), e); } finally { folder = null; getStore().notifyConnectionListeners(ConnectionEvent.CLOSED); } } }