Get mail backward date?

I want to read mail backward follow input from user (input dialog)

Now I use Get outlook activity and use filter as below.

“[ReceivedTime] >= '”+now.AddDays(-(Convert.ToInt32(backDate.ToString))).Date.tostring(“dd/MM/yyyy”)+"’"

Example : I key input = 1
That mean read mail that received today only.

But now It read mail yesterday until today.


Please guide me about it.

It works as expected, isn’t?

today = 10/8
today.addDays(-1) = 10/7
ReceivedTime >= 10/7

In case you want mail of today ONLY the key input should be 0 (zero)


What exactly do you want to read? The formula you posted above simply substracts 1 day (with your given input) and then it limits the filter to [yesterday → today].

Also, note that Datetime.Now.AddDays(-1) would go from yesterday to today, based on the hour as well, not just the day. If it is 8 PM, you would substract 24h and would be getting all the mails received at 8PM yesterday as well.

I would recommend something like this:


0 - would be for the current day
-1 - would be for yesterday and so on

@Sergiu.Wittenberger I use filter that your suggest as below.

“[ReceivedTime] >= '”“dd/MM/yyyy”)+"’"

backDate = 0

But don’t get mail today to me.

Please guide me for solve it.

@J0ska If I key backdate = 0. It not get mail today to me.

I recommend you to check the reference. There are filtering examples which you need.


1 Like


If you check below it has gives you very specify result including the time
Maybe you don’t have the results at that time

You can check below to get the today’s mails as below

Hope this may help you



Change the condition like this
And give a try

“[ReceivedTime] > '”+now.AddDays(-(Convert.ToInt32(backDate.ToString))).Date.tostring(“dd/MM/yyyy”)+"’"

It won’t give yesterday mail and give only today’s mail

Cheers @Maria99

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.