EWS 托管 API:通过 DateTimeReceived 上的搜索过滤器获取电子邮件 [英] EWS Managed API: Fetch emails by search filter on DateTimeReceived

查看:39
本文介绍了EWS 托管 API:通过 DateTimeReceived 上的搜索过滤器获取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在收件箱中搜索在特定时间范围后收到的项目时(如下面的代码所述).它会搜索日期,但也会返回带有指定时间戳的电子邮件.我只想要指定时间戳之后的电子邮件.

While searching for items in the inbox that have been received after a particular time frame (as mentioned in the code below). It searches for the date but it is also returning the email with the specified timestamp. I want the emails only after the specified timestamp.

SearchFilter greaterthanfilter = new SearchFilter.IsGreaterThan(ItemSchema.DateTimeReceived,
                    Convert.ToDateTime(lastUploadedEmailtimeStamp));

mailItems = inbox.FindItems(greaterthanfilter, view);

不确定是否有人遇到过类似的问题?基本上我想搜索在特定 mm/dd/yyyy hh:mm:ss 之后收到的项目.

Not sure if anyone has faced any similar issues? Basically I want to search for items that were received after a particular mm/dd/yyyy hh:mm:ss.

推荐答案

Exchange 以精确到毫秒的精度存储日期时间,EWS 只为您提供精确到秒的日期时间,但是 Searchfilters 确实具有毫秒的精度约会时间.因此,如果您使用的日期时间戳只有秒的精度,那么您需要使用类似这样的东西,例如您想要在 7:43 和 8 秒后收到的所有电子邮件

Exchange stores the datetimes with a precision down to the Millisecond, EWS only give you a precision on datetimes to the second however the Searchfilters do have a precision of milliseconds with Date time. So if you datetime stamps your using only have a precision of seconds then you need to use something like this eg where you wanted all email that was received after 7:43 and 8 seconds

SearchFilter sfs = new SearchFilter.IsGreaterThan(ItemSchema.DateTimeReceived, DateTime.ParseExact("2014/12/29 07:43:08.999", "yyyy/MM/dd HH:mm:ss.fff", null));
FindItemsResults<Item> femaa = service.FindItems(WellKnownFolderName.Inbox,sfs, iItemView);

如果您想查看邮件的实际精度,您需要使用 MAPI 编辑器,例如 MFCMapi 的 OutlookSpy.然后,您可以查看 PT_Systime 值,它是 FileTime8 个字节;一个 64 位整数,表示自 1601 年 1 月 1 日以来的 100 纳秒间隔数",请参阅 http://msdn.microsoft.com/en-us/library/ee157583(v=EXCHG.80).aspx

If you want to look at the actual precision on your messages you need to use a MAPI editor like OutlookSpy of MFCMapi. You can then look at the PT_Systime value which are FileTime "8 bytes; a 64-bit integer representing the number of 100-nanosecond intervals since January 1, 1601" see http://msdn.microsoft.com/en-us/library/ee157583(v=EXCHG.80).aspx

干杯格伦

这篇关于EWS 托管 API:通过 DateTimeReceived 上的搜索过滤器获取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆