Question

I want to download mails that matches the in-place eDiscovery. I do a GetDiscoverySearchConfiguration(), then I execute SearchMailboxes() for each mailbox that GetDiscoverySearchConfiguration() returns. SearchMailboxes() returns SearchPreviewItems() where I can get the real EmailMessage Id but this does not have the email body, so I have to do another retrieve using FindItems() to get the EmailMessage object.

This is a very slow process, are there any other way to do this?

I would like to get all the mails that I can see in the preview

Was it helpful?

Solution

Instead of FindItems(), use the ExchangeService.BindToItems() method and provide a collection of the message ids you want in batches. Restrict the property set to only the properties you need. A couple of other thoughts: - Limit the preview response shape to just the item identifiers since you'll call BindToItems for the properties you need. - FindItems will only return the first 512 characters of the body. - Use paging with SearchMailboxes(). Optimal page size will depend on the property set. You'd have to test different page sizes to optimize.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top