OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
868 stars 559 forks source link

How to fetch/retrieve the mails via DateTimeReceived filter in JAVA #735

Open Manish123chandel opened 4 years ago

Manish123chandel commented 4 years ago

Hi , I'm trying to fetch the mail on dateTime basis from the email via ews-java api. in INboc mail exist with different different time so i want to filter out the mail which fulfill our requirement only. I am trying with the below code but it's not giving the expected result. String str = "Jul 15 2020 13:13:38 IST"; SimpleDateFormat df = new SimpleDateFormat("MMM dd yyyy HH:mm:ss zzz"); Date date = null; try{ date = df.parse(str); } catch( ParseException e ){ e.printStackTrace( ); } SearchFilter isGreaterThan = new SearchFilter.IsLessThanOrEqualTo(ItemSchema.DateTimeReceived, date); List <EmailMessage> items1 = SearchEmail.withCriteria(isGreaterThan, 10, TimeUnit.SECONDS).answeredBy(t);

above code, in item1 it is returning all the mails i.e it is not able to filter the mail acording to SearchFilter. If I use SearchFilter.isEqualTo() then it return o mails although there is mail exist with given date.

Can you please help me on this how to fetch the mail on given date and time via ews-java-API in JAVA.

cumulate commented 8 months ago

@Manish123chandel were you able to slove this?