Example usage for javax.mail.internet MimeMessage isSet

List of usage examples for javax.mail.internet MimeMessage isSet

Introduction

In this page you can find the example usage for javax.mail.internet MimeMessage isSet.

Prototype

@Override
public synchronized boolean isSet(Flags.Flag flag) throws MessagingException 

Source Link

Document

Check whether the flag specified in the flag argument is set in this message.

Usage

From source file:com.adaptris.mail.MailClientImp.java

@Override
public void setMessageRead(MimeMessage msg) throws MailException {
    try {/*  ww  w. ja  v  a  2  s .  c o  m*/
        if (msg.isSet(Flags.Flag.SEEN) || msg.isSet(Flags.Flag.DELETED)) {
            return;
        }
        msg.setFlag(Flags.Flag.SEEN, true);
        msg.setFlag(Flags.Flag.DELETED, deleteFlag);
        try {
            // When accessing a POP3 mailbox the sun provider
            // doesn't allow you to save changes to the message
            // status (curious)
            // To delete the messages, you should do setPurge(true);
            // This will work with imap mailboxes

            // Note that this does nothing for ComsNetClient
            msg.saveChanges();
        } catch (Exception e) {
            ;
        }
    } catch (Exception e) {
        throw new MailException(e);
    }
}

From source file:com.adaptris.mail.MailClientImp.java

protected boolean accept(MimeMessage m) throws MessagingException {
    boolean accept = false;
    if (m.isSet(Flags.Flag.SEEN) || m.isSet(Flags.Flag.DELETED)) {
        return accept;
    }// w  ww. j a va2  s  .c o m
    int matches = 0;
    for (MessageFilter mf : filters) {
        if (mf.accept(m)) {
            matches++;
        }
    }
    if (matches == filters.size()) {
        log.trace("message [{}] matches filters", m.getMessageID());
        accept = true;
    } else {
        log.trace("Ignoring message [{}] filters not matched", m.getMessageID());
    }
    return accept;
}