1

I am trying to filter items in a folder using the code below:

sFilter = "[ReceivedTime] > '9/20/2014'";
items = InboxFolder.Items; // Line 1
items = InboxFolder.Items.Restrict(sFilter); //Line 2

When line 2 executes, it returns the items of 9/20/2014

I want items of 9/21/2014 (as ReceivedTime > 9/20/2014).

How can I get items for today, i.e. ReceivedTime = Today's Date?

Find Method is also not working.

Community
  • 1
  • 1
Pradip
  • 1,507
  • 11
  • 28

2 Answers2

1

you can try by changing sFilter :

sFilter =" [ReceivedTime] >= '2014-09-21 00:00' "
Mohammad Arshad Alam
  • 9,694
  • 6
  • 38
  • 61
0

Outlook interop needs some specific Date Format as a parameter of Restrict method.

you can use equal to sign with greater than >=

please convert your Date Format into this ('MM/dd/yyyy HH:mm'), please make sure to put your date into a single quote.

var filter = "[ReceivedTime] >='" + DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "' ";

In your case it would be fine also

sFilter = "[ReceivedTime] >= '09/20/2014'";

To get emails between two dates then you can use and operator

sFilter = "[ReceivedTime] >= '09/20/2014' and [ReceivedTime] <= '09/28/2014'";

you can use this format also

var filter = "[ReceivedTime] >='" + DateTime.Now.ToString("g") + "' ";