Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
823 views
in Technique[技术] by (71.8m points)

email - java imap fetch messages since a date

I am writing/learning to fetch email using java from an IMAP folder using javax.mail package. I was successfully able to retrieve the last n messages in a Folder, however I am looking to build an example to retrieve messages since a specified date. Any examples?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could also use the SearchTerm classes in the java mail package.

SearchTerm olderThan = new ReceivedDateTerm(ComparisonTerm.LT, someFutureDate);
SearchTerm newerThan = new ReceivedDateTerm(ComparisonTerm.GT, somePastDate);
SearchTerm andTerm = new AndTerm(olderThan, newerThan);
inbox.search(andTerm);

Some combination of the above should prove to be a better way to get dates within a certain range.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...