I have written a sample code that bring email of one folder of Outlook email account between given date range. I am using Java Mail API 1.5 and Java 7.

For getting messages, I have written below code that search emails since 1-Jan-1970 to before 30-Oct-2013 -


Date FutureDate = new Date(2013 - 1900, 9, 30, 00, 00, 00);

Date PastDate = new Date(1970 - 1900, 0, 1);

SearchTerm newerThen = new ReceivedDateTerm(ComparisonTerm.LE, FutureDate);

SearchTerm olderThen = new ReceivedDateTerm(ComparisonTerm.GE, PastDate);

SearchTerm andTerm = new AndTerm(olderThen, newerThen);

Message[] msg = folder.search(andTerm);

Last week, this method is working fine for me. After that I didn't make any changes in my Mail API or other code too. but today when I try to run above code that code is returning zero length msg i.e. no message is found since 1-Jan-1970 to before 30-Oct-2013, though my folder contains 204 emails between this range.

Surprisingly, the same code working fine to search email of folders of Gmail as well as of Yahoo IMAP account.

Is there any problem with IMAP in outlook mail account.

When printing any emails received, all of the folders and advertising on the page and the headers and footers also print.  How can this be fixed?