In my application i am trying to use java mail API to read through one mailbox where we recieve bounced email records, i believe we can fetch all the messages using
// Get a Store object that implements the specified protocol.
store = session.getStore(protocol);
//Connect to the current host using the specified username and password.
store.connect(hostName, userName, password);
folder = store.getFolder(folderName);
Message[] messages = folder.getMessages();
However this would return me all the messages in the provided folder, Is there a way where in i can find out the messages which i received yesterday on in a given date range.
Any help in this regard would be highly appreciated.
Thanks
Vaibhav
解决方案
Following changes i did to make this work as per my expectations:
cal.add(Calendar.DAY_OF_MONTH, -1);
// We would get the bounce mails received yesterday
ReceivedDateTerm term = new ReceivedDateTerm(ComparisonTerm.EQ,newDate(cal.getTimeInMillis()));
Message[] messages = folder.search(term)
Cheers!
Vaibhav