I have a question about loading methods for EWS. I have a lot of messages in my outlook and I'm also using EWS and WinForms.
Right know my code is this:
while (more)
{
FindItemsResults<Item> findResults1 = allItemsFolder.FindItems("System.Message.DateReceived:01/01/2011..12/31/2022", iv);
foreach (var item in findResults1)
{
if (item.GetType() == typeof(Microsoft.Exchange.WebServices.Data.EmailMessage))
{
listik.Add(item);
}
}
more = findResults1.MoreAvailable;
if (more)
{
iv.Offset = 1000;
}
}
It took 12 minutes already for me for running my application and I decided to stop it, because something is wrong. I think I have more than 61k messages.
Anyone can help me with that?
CodePudding user response:
I would try to remove the search and try again its pretty pointless anyway with such a broad date range, the all items folder is a search folder so your applying one search on top of the other which generally doesn't work well. Also use a property set to limit the result that is returned to just the properties you want which will also make the query run faster eg
iv.PropertySet =
new PropertySet(
BasePropertySet.IdOnly,
ItemSchema.Subject);
CodePudding user response:
No email app, including Outlook, ever loads all messages in a folder. Use a virtual listview/grid and retrieve the messages (using the appropriate offset) only when displaying them to an end user.