使用过滤器在特定日期之后修改任务

时间:2013-10-16 09:29:56

标签: c# .net-4.0 exchangewebservices

您对EWS的SearchFilter有什么经验吗?我正在尝试使用last modified time比变量date的值更新的任务。它真的以奇怪的方式使用这段代码,我也尝试将日期更改为UTC时间格式。我有什么建议我做错了吗?

        //Create the extended property definition.
        ExtendedPropertyDefinition taskLastUpdate = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Task, 0x3008, MapiPropertyType.SystemTime);

        //Create the search filter.
        SearchFilter.IsGreaterThanOrEqualTo filter = new SearchFilter.IsGreaterThanOrEqualTo(taskLastUpdate, date.ToString("s") + "Z");
        //Get the tasks.
        FindItemsResults<Item> tasks = _service.FindItems(WellKnownFolderName.Tasks, filter, new ItemView(100));

1 个答案:

答案 0 :(得分:2)

我不确定为什么它与ExtendedPropertyDefinition不起作用。

解决方案:

SearchFilter greaterthanfilter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.LastModifiedTime, date );
SearchFilter filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, greaterthanfilter);
Folder folder = Folder.Bind(_service, WellKnownFolderName.Tasks); //Or the folder you want to search in
FindItemsResults<Item> results = folder.FindItems(filter, new ItemView(1000));