I've been trying to retrieve items for deletion out of an Outlook public folder with just over 2 million items. However, even with a page size of 10, FindItems takes forever to return, as if it were querying every single item in the folder. So far it hasn't returned after 2 hours. Is there a way to keep it from doing this?
var folder = GetPublicFolder(service);
folder.Load();
var items = folder.FindItems(new ItemView(10)
{
Traversal = ItemTraversal.Shallow
});
Only way to retrieve items from a folder this big is to use PropertySet.IdOnly while finding the items and adjust your batch size accordingly. I was also unable to do any filtering of this without timing out.
items = folder.FindItems(new ItemView(100)
{
Traversal = ItemTraversal.Shallow,
PropertySet = PropertySet.IdOnly
});
service.LoadPropertiesForItems(items, new PropertySet(ItemSchema.DateTimeReceived,
ItemSchema.Subject));
Then iterate over the batch and do what you will with the items while keeping what you load to a minimum. Do to being unable to filter, you can only grab the items off of the top, so to do most anything you'll need to move processed items to a separate folder between batches.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.