public MessagesWrapper markAsRead(List<Message> messagez)
     throws IOException, MessagingException {
   if (folder.isOpen() && folder.getMode() != Folder.READ_WRITE) {
     folder.close(true);
   }
   if (!folder.isOpen()) {
     folder.open(Folder.READ_WRITE);
   }
   for (Message message : messagez) {
     message.setFlag(Flags.Flag.SEEN, true);
   }
   logger.info("Marked email(s) as read : " + messagez.size());
   return this;
 }
 public MessagesWrapper search(List<SearchTerm> term) throws MessagingException {
   if (!folder.isOpen()) {
     folder.open(Folder.READ_ONLY);
   }
   Message[] messages = folder.search(and(term));
   return new MessagesWrapper(logger, Arrays.asList(messages), folder);
 }
예제 #3
0
  public void scanWholeFolder() throws MessagingException {
    if (folder.isOpen() == false) {
      folder.open(Folder.READ_WRITE);
    }

    // Bulk-fetch the message envelopes.
    Message[] newMessages = folder.getMessages();
    FetchProfile fetchProfile = new FetchProfile();
    // FIXME: add CONTENT_INFO if we start to display the size
    // fetchProfile.add(FetchProfile.Item.CONTENT_INFO);
    fetchProfile.add(FetchProfile.Item.ENVELOPE);
    fetchProfile.add(FetchProfile.Item.FLAGS);
    folder.fetch(newMessages, fetchProfile);

    this.messages = new ArrayList<Message>();
    messages.addAll(Arrays.asList(newMessages));

    fireTableDataChanged();
  }