示例#1
0
  /**
   * Retrieves headers of new messages.
   *
   * @return a string array containing the message headers
   */
  public String[] getNewMessageHeaders() throws Exception {
    logger.info("[Inbound:MailServerFolder] Calling getNewMessageHeaders");
    reopen(); // Make sure the folder is open

    //
    // Deliver only new messages to the MDB
    //

    try {
      if (folder.hasNewMessages()) {
        int newMsgs = folder.getNewMessageCount();
        int msgCount = folder.getMessageCount();
        Message[] msgs = folder.getMessages(msgCount - newMsgs + 1, msgCount);
        String[] headers = new String[msgs.length];
        logger.log(Level.INFO, "messages length: {0}", msgs.length);
        logger.log(Level.INFO, "headers length: {0}", headers.length);
        for (int i = 0; i < headers.length; i++) {
          logger.log(
              Level.INFO,
              "[Inbound:MailServerFolder] Packing message with SUBJECT: {0}",
              msgs[i].getSubject());
          headers[i] = msgs[i].getSubject();
        }
        return headers;
      }
    } catch (Exception e) {
      logger.severe("[Inbound:MailServerFolder] Exception obtaining messages from mail server:");
    }
    return null;
  }
示例#2
0
  public boolean hasNewMessages() throws Exception {
    logger.info("[Inbound:MailServerFolder] Calling hasNewMessages");
    reopen(); // Make sure the folder is open

    /**
     * ** logger.info("Folder <" + folder.getName() + "> has (" + folder.getUnreadMessageCount() +
     * ") unread messages"); logger.info("Folder <" + folder.getName() + "> has (" +
     * folder.getNewMessageCount() + ") NEW messages"); **
     */
    return folder.hasNewMessages();
  }
示例#3
0
  /**
   * Retrieves new messages.
   *
   * @return an array of messages
   */
  public Message[] getNewMessages() throws Exception {
    logger.info("[Inbound:MailServerFolder] Calling getNewMessages");
    reopen(); // Make sure the folder is open

    //
    // Deliver only new messages to the MDB
    //

    try {
      if (folder.hasNewMessages()) {
        int newMsgs = folder.getNewMessageCount();
        int msgCount = folder.getMessageCount();
        Message msgs[] = folder.getMessages(msgCount - newMsgs + 1, msgCount);
        return msgs;
      }
    } catch (Exception e) {
      logger.info("[Inbound:MailServerFolder] Exception obtaining messages from mail server");
    }
    return null;
  }