EWS - 在 Exchange Web Services 2007 中查找上次日历修改
本文关键字:查找 日历 修改 2007 Exchange Web Services EWS | 更新日期: 2023-09-27 18:33:33
我是 EWS Web 服务的新用户,可以处理不同的功能以使它们工作(FindItem、FindFolder、getItem 等)但我无法解决这个问题:我尝试在日历文件夹中查找约会的所有最新修改或创建。我的第一个想法是创建一个 FindItemType 请求,对 LastModificationDate 扩展字段( PropertyId = 0x3008) 有限制,并调用 findItem 方法。
我尝试了以下代码,但结果始终为空(主动脉。项目 == 空):
_esb = new ExchangeServiceBinding();
_esb.Url = serviceUrl;
_esb.Credentials = new NetworkCredential
{
UserName = userName,
Password = password,
Domain = domain
};
// snipped...
FindItemType fit = new FindItemType
{
ItemShape = new ItemResponseShapeType
{
BaseShape = DefaultShapeNamesType.IdOnly
},
ParentFolderIds = folderTypes,
Traversal = ItemQueryTraversalType.Shallow,
Restriction = new RestrictionType
{
Item = new IsGreaterThanOrEqualToType
{
FieldURIOrConstant = new FieldURIOrConstantType
{
Item = new ConstantValueType { Value = lastModifiedDateSearched.ToUniversalTime().ToString("u") }
},
Item = new PathToExtendedFieldType
{
DistinguishedPropertySetIdSpecified = true,
DistinguishedPropertySetId = DistinguishedPropertySetType.Appointment,
PropertyType = MapiPropertyTypeType.SystemTime,
PropertyId = 0x3008,
PropertyIdSpecified = true,
}
}
}
};
FindItemResponseType response = _esb.FindItem(fit);
List<ItemIdType> res = new List<ItemIdType>();
foreach (FindItemResponseMessageType firmt in response.ResponseMessages.Items.Where(c => c.IsNotNull()))
{
if (firmt.RootFolder.IsNotNull())
{
ArrayOfRealItemsType aorit = firmt.RootFolder.Item as ArrayOfRealItemsType;
if (aorit != null && aorit.Items.IsNotNull())
{
foreach (ItemType item in aorit.Items)
{
if (item.ItemId.IsNotNull())
{
res.Add(item.ItemId);
}
}
}
}
}
有人知道我的查询是否正确吗?我是否使用正确的方法来执行此操作?感谢您的帮助。
挖了又挖,然后...我终于找到了问题所在。未正确声明 PathToExtendedFieldType。应该很简单:
new PathToExtendedFieldType
{
PropertyType = MapiPropertyTypeType.SystemTime,
PropertyTag = "0x3008"
}