Java Code Examples for javax.mail.Message#isSet()
The following examples show how to use
javax.mail.Message#isSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MailConnection.java From hop with Apache License 2.0 | 5 votes |
public boolean isMessageNew( Message msg ) {
try {
return msg.isSet( Flag.RECENT );
} catch ( MessagingException e ) {
return false;
}
}
Example 2
Source File: MailConnection.java From hop with Apache License 2.0 | 5 votes |
public boolean isMessageRead( Message msg ) {
try {
return msg.isSet( Flag.SEEN );
} catch ( MessagingException e ) {
return false;
}
}
Example 3
Source File: MailConnection.java From hop with Apache License 2.0 | 5 votes |
public boolean isMessageFlagged( Message msg ) {
try {
return msg.isSet( Flag.FLAGGED );
} catch ( MessagingException e ) {
return false;
}
}
Example 4
Source File: MailConnection.java From hop with Apache License 2.0 | 5 votes |
public boolean isMessageDeleted( Message msg ) {
try {
return msg.isSet( Flag.DELETED );
} catch ( MessagingException e ) {
return false;
}
}
Example 5
Source File: MailConnection.java From hop with Apache License 2.0 | 5 votes |
public boolean isMessageDraft( Message msg ) {
try {
return msg.isSet( Flag.DRAFT );
} catch ( MessagingException e ) {
return false;
}
}
Example 6
Source File: MailConnection.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean isMessageNew( Message msg ) {
try {
return msg.isSet( Flag.RECENT );
} catch ( MessagingException e ) {
return false;
}
}
Example 7
Source File: MailConnection.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean isMessageRead( Message msg ) {
try {
return msg.isSet( Flag.SEEN );
} catch ( MessagingException e ) {
return false;
}
}
Example 8
Source File: MailConnection.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean isMessageFlagged( Message msg ) {
try {
return msg.isSet( Flag.FLAGGED );
} catch ( MessagingException e ) {
return false;
}
}
Example 9
Source File: MailConnection.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean isMessageDeleted( Message msg ) {
try {
return msg.isSet( Flag.DELETED );
} catch ( MessagingException e ) {
return false;
}
}
Example 10
Source File: MailConnection.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean isMessageDraft( Message msg ) {
try {
return msg.isSet( Flag.DRAFT );
} catch ( MessagingException e ) {
return false;
}
}
Example 11
Source File: JavaMailContainer.java From scipio-erp with Apache License 2.0 | 4 votes |
protected void checkMessages(Store store, Session session) throws MessagingException {
if (!store.isConnected()) {
store.connect();
}
// open the default folder
Folder folder = store.getDefaultFolder();
if (!folder.exists()) {
throw new MessagingException("No default (root) folder available");
}
// open the inbox
folder = folder.getFolder(INBOX);
if (!folder.exists()) {
throw new MessagingException("No INBOX folder available");
}
// get the message count; stop if nothing to do
folder.open(Folder.READ_WRITE);
int totalMessages = folder.getMessageCount();
if (totalMessages == 0) {
folder.close(false);
return;
}
// get all messages
Message[] messages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
profile.add(FetchProfile.Item.FLAGS);
profile.add("X-Mailer");
folder.fetch(messages, profile);
// process each message
for (Message message: messages) {
// process each un-read message
if (!message.isSet(Flags.Flag.SEEN)) {
long messageSize = message.getSize();
if (message instanceof MimeMessage && messageSize >= maxSize) {
Debug.logWarning("Message from: " + message.getFrom()[0] + "not received, too big, size:" + messageSize + " cannot be more than " + maxSize + " bytes", module);
// set the message as read so it doesn't continue to try to process; but don't delete it
message.setFlag(Flags.Flag.SEEN, true);
} else {
this.processMessage(message, session);
if (Debug.verboseOn()) {
Debug.logVerbose("Message from " + UtilMisc.toListArray(message.getFrom()) + " with subject [" + message.getSubject() + "] has been processed." , module);
}
message.setFlag(Flags.Flag.SEEN, true);
if (Debug.verboseOn()) {
Debug.logVerbose("Message [" + message.getSubject() + "] is marked seen", module);
}
// delete the message after processing
if (deleteMail) {
if (Debug.verboseOn()) {
Debug.logVerbose("Message [" + message.getSubject() + "] is being deleted", module);
}
message.setFlag(Flags.Flag.DELETED, true);
}
}
}
}
// expunge and close the folder
folder.close(true);
}
Example 12
Source File: EmailUtils.java From testgrid with Apache License 2.0 | 2 votes |
public boolean isMessageUnread(Message message) throws Exception {
return !message.isSet(Flags.Flag.SEEN);
}