use of javax.mail.FetchProfile in project xwiki-platform by xwiki.
the class MailPluginApi method getMailHeaders.
public Message[] getMailHeaders(String provider, String server, String user, String password) throws MessagingException {
// Get a session. Use a blank Properties object.
Session session = Session.getInstance(new Properties());
// Get a Store object
Store store = session.getStore(provider);
store.connect(server, user, password);
try {
// Get "INBOX"
Folder fldr = store.getFolder("INBOX");
fldr.open(Folder.READ_ONLY);
Message[] messages = new Message[fldr.getMessageCount()];
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.CONTENT_INFO);
profile.add(FetchProfile.Item.ENVELOPE);
profile.add(FetchProfile.Item.FLAGS);
fldr.fetch(messages, profile);
return messages;
} finally {
store.close();
}
}
use of javax.mail.FetchProfile in project spring-integration by spring-projects.
the class AbstractMailReceiver method fetchMessages.
/**
* Fetches the specified messages from this receiver's folder. Default
* implementation {@link Folder#fetch(Message[], FetchProfile) fetches}
* every {@link javax.mail.FetchProfile.Item}.
*
* @param messages the messages to fetch
* @throws MessagingException in case of JavaMail errors
*/
protected void fetchMessages(Message[] messages) throws MessagingException {
FetchProfile contentsProfile = new FetchProfile();
contentsProfile.add(FetchProfile.Item.ENVELOPE);
contentsProfile.add(FetchProfile.Item.CONTENT_INFO);
contentsProfile.add(FetchProfile.Item.FLAGS);
this.folder.fetch(messages, contentsProfile);
}
Aggregations