本文整理汇总了C#中Folder.FindItems方法的典型用法代码示例。如果您正苦于以下问题:C# Folder.FindItems方法的具体用法?C# Folder.FindItems怎么用?C# Folder.FindItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder.FindItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItem
internal List<Item> GetItem(Folder folder, ItemView iView, DateTime startDate, DateTime endDate, string subjectToSearch)
{
SearchFilter.SearchFilterCollection searchFilterCollection = new SearchFilter.SearchFilterCollection(LogicalOperator.And);
searchFilterCollection.Add(new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, startDate));
searchFilterCollection.Add(new SearchFilter.IsLessThanOrEqualTo(ItemSchema.DateTimeReceived, endDate));
if (!String.IsNullOrEmpty(subjectToSearch))
{
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, subjectToSearch));
}
SearchFilter searchFilter = searchFilterCollection;
FindItemsResults<Item> findResult = folder.FindItems(searchFilter, iView);
return this.GetListItem(findResult);
}
示例2: MarkAllAsRead
static void MarkAllAsRead(Folder folder)
{
if (folder.ChildFolderCount == 0)
{
ItemView itemView = new ItemView(100);
itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.IsRead);
SearchFilter filter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false);
folder.FindItems(filter, itemView)
.Cast<EmailMessage>()
.ToList()
.ForEach(item =>
{
item.IsRead = true;
item.Update(ConflictResolutionMode.AutoResolve);
});
}
else
{
FolderView folderView = new FolderView(folder.ChildFolderCount);
folder.FindFolders(folderView).ToList().ForEach(child => MarkAllAsRead(child));
}
}
示例3: GetItemIds
private static List<ItemId> GetItemIds(Folder source, ExchangeService service, ItemTraversal traversal)
{
// Collect the Ids of all the items in the folder
List<ItemId> itemIds = new List<ItemId>();
FindItemsResults<Item> findResults = null;
while (findResults == null || findResults.MoreAvailable == true)
{
DebugLog.WriteVerbose("Calling FindItems.");
ItemView view = new ItemView(
GlobalSettings.DumpFolderViewSize,
itemIds.Count);
view.Traversal = traversal;
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
findResults = source.FindItems(view);
DebugLog.WriteVerbose(String.Concat("FindItems returned {0} items", findResults.Items.Count));
foreach (Item foundItem in findResults.Items)
{
itemIds.Add(foundItem.Id);
}
}
return itemIds;
}
示例4: GetFolderItems
public List<Item> GetFolderItems(Folder folder)
{
const int pageSize = 100;
int offset = 0;
bool moreItems = true;
List<Item> result = new List<Item>(folder.TotalCount);
ItemView oView = new ItemView(pageSize, offset, OffsetBasePoint.Beginning);
oView.PropertySet = ItemPropertySet;
while (moreItems)
{
oView.Offset = offset;
FindItemsResults<Item> findResult = folder.FindItems(oView);
result.AddRange(findResult.Items);
if (!findResult.MoreAvailable)
moreItems = false;
if (moreItems)
offset += pageSize;
}
return result;
}