Recursive folder search with Exchange Web Services in single call?
Posted on 2011-09-08
My C# application mines email data from exchange via EWS, searches usually take 1-2 minutes. I recently ran into a client where it is taking ~60 minutes to retrieve one user's data. I am trying to figure out a way to bring that number down, even getting it down to 30 minutes would probably work. The user in question has a 17GB mailbox with many folders and subfolders (I don't know the exact number). I suspect the folder tree is more of a problem than the actual mail volume, I'll get to that in a minute.
I currently enumerate all the folders in a user's mailbox and then make a "FindItems" call to each folder using a search filter to retrieve only the last day's worth of data. I suspect that what's taking a lot of time is just making all those calls for folders which probably don't even have data we need anyway. Is there a way to just make one recursive call to the inbox? Ultimately the data I end up getting back isn't a lot, I have other users with a lot higher daily volume of mail which I can retrieve quickly, I think because they don't have the complex folder tree which this user has.