1
我是EWS Web服務的新用戶,可以處理不同的功能以使它們工作(FindItem,FindFolder,getItem等...) 但我無法解決這一個: 我試圖找到日曆文件夾中的約會的所有最新修改或創建。 我的第一個想法是在LastModificationDate擴展字段(PropertyId = 0x3008)上創建一個限制FindItemType請求並調用findItem方法。EWS - 在Exchange Web Services 2007中查找上次日曆修改
我嘗試下面的代碼,但結果始終是空的(aorit.Items == NULL):
_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);
}
}
}
}
}
有誰知道,如果我的查詢似乎是正確的?我是否用正確的方式來做到這一點? 感謝您的幫助。