i have scenario wherein i have to fetch mail on basis of received time and subject and mark it as read only to that particular mail item strictly. for this purpose i have written down a outlook filter query
which is as follow
and it work this time but my local time is 11/12/2018 23:40.
so now i am focusing on issue with different approach if you have any solution on this then that would be very helpful for me.
issue is in filter it compares mail time in header with time with PST timezone not with IST time zone so if i do -5.30 hrs minus then it is working not looking for how to use IST time.
My thinking was this:
Let’s say you receive a mail that has time in header as “12:00” in PST
Then, you try to filter by a time that is in IST, so it looks for emails after “15:30”.
If you filter it like this, you will never find emails because IST is several hours after the mail time.
So, what I am suggesting is that you convert the time you are comparing with to PST or whatever time that the mails will be going by.
For example, if your current time is stored as Now, you can change it like this: Now.ToUniversalTime.AddHours(-8).ToString("dd/MM/yyyy HH:mm"
And, concatenate that inside your filter so it’s in the right format.
Now, there is also another way to filter your mails if you choose to take another approach. You can just bring in all mails within a certain number, then use LINQ in vb.net. However, this can sometimes be slower since you need to bring in more emails. This would use the date in the header and a condition to check it with your current time (again you would need to make sure the dates are in the same timezone by converting both sides to UTC). Would look something like this basically, mailmsg.Where(Function(m) CDate(m.Headers(0)).ToUniversalTime >= Now.ToUniversalTime).ToArray
correct i am doing same that subtracting IST -5.30 hrs from mail time and finding the mail.
as u suggested ill try doing this with help of linq query just wanted to know can i check subject line also in that ?