none
Pro-grammatically searching all emails (across mailboxes) RRS feed

  • Question

  • I had a look at ExMerge, its a UI tool. We need to be able to search all users mailboxes based on the value of a MAPI property. There is no constraint on the development tool to use. We can use Exchange console and script the task out, use EWS and write some .Net code or pretty much use any development option to be able to search the entire Exchange mail store.

    One option obviously is to extract all mailboxes and then search each mailbox. But we would really prefer if we can get a way to search across the exchange server (2010 and upwards).

    Is this possible? Can someone please point in the right direction if it is.


    I always think tomorrow will have more time than today. And every today seems to pass-by faster than yesterday.
    Rahul Singla | http://www.rahulsingla.com

    Monday, August 12, 2013 7:33 AM

All replies

  • hm, I don't know of any method that would let you search every mailbox in a single query. The only thing I can think of that comes close is to use jobs to search multiple mailboxes simultaneously, which however will give you a swift encounter with the maximum # of connections limit of EWS.

    What I'd use, if I had to do this, would be EWS managed Api and use the findItems method of the ExchangeService object on each mailbox. I don't know how that scales on the number of mailboxes though, so I do not know whether it's practicable for your scenario.

    If there's a way to truely search across all mailboxes, I'd be rather interested in the method myself.

    Monday, August 12, 2013 11:39 AM
  • If there's a way to truely search across all mailboxes, I'd be rather interested in the method myself.

    How does ExMerge does it then, I didn't look at its detailed functionality but seems like it can.

    I would like to think if I have Exchange server admin credentials, I should be able to run a global query. Iterating mailboxes and then searching is obviously the last resort :)


    I always think tomorrow will have more time than today. And every today seems to pass-by faster than yesterday.
    Rahul Singla | http://www.rahulsingla.com


    Monday, August 12, 2013 1:48 PM
  • Hello Rahul Singla,

    I did a bit more research on the topic. First of all, the only ExMerge tool I found on a shallow search was aimed at Exchange 2003 (though it could be made to work with 2007 or 2010). Which means it does not use EWS, moving it beyond the scope of what I have any experience with :(

    However, I did a bit more research on EWS, and looking through the Api, it might just be that at least Exchange 2013 might have some EWS tools for the job: The ExchangeService class has a method named searchMailboxes, which may or may not serve your needs. I don't yet have any Exchange 2013 to play with, so I can't try it out myself, but maybe someone else out here knows a bit more on the topic.

    In the hope I helped (or at least prevented you from feeling ignored),
    Fred

    Good Luck

    Monday, August 12, 2013 4:47 PM
  • In the hope I helped (or at least prevented you from feeling ignored),

    Fred

    Good Luck

    Hi Fred, the replies have certainly been helpful, and it feels I am in good company :)

    Hopefully we can get a definite reply on the topic here soon, thanks for your research and help.


    I always think tomorrow will have more time than today. And every today seems to pass-by faster than yesterday.
    Rahul Singla | http://www.rahulsingla.com

    Tuesday, August 13, 2013 5:37 AM
  • Hi,

    Is it a requirement to do this programmatically, or can you use in-built functionality to perform this?

    Exchange has inbuilt functionality to search for items in other mailboxes, this functionality is called "Discovery Search". Take a look here: http://technet.microsoft.com/en-us/library/dd335072(v=exchg.141).aspx


    MCITP Ent. Messaging | MCTS | MCSA | MCP
    http://www.camm.id.au (blog)

    Tuesday, August 13, 2013 6:33 AM
  • It depends on the particular MAPI property you want to search and if that property is Indexed by Exchange Search you can see a full list of Indexed Properties on http://technet.microsoft.com/en-us/library/jj983804(v=exchg.150).aspx.  If the property you want to search for is indexed then in EWS you can use an AQS query and query every folder in a Mailbox. (or you could do a discovery search in EMS as somebody else has suggested using the AQS filter).

    In Exchange 2013 search has be significantly upgraded and if you have an Indexed property then you can use eDiscovery and a KQL query to search all folders in a Mailbox in one operation.

    If you have an unindexed property you going to have to in EWS uses a SearchFilter http://msdn.microsoft.com/en-us/library/dd633659(v=exchg.80).aspx  to query every folder or you may want to use MAPI using something like Redemption http://www.dimastr.com/redemption/mapitable.htm and use MAPITables. Each of these methods will require you to search every folder in the mailbox and depending on ItemCounts will take time.

    Cheers
    Glen

     
    Tuesday, August 13, 2013 7:00 AM
  • Hi,

    Is it a requirement to do this programmatically, or can you use in-built functionality to perform this?

    Exchange has inbuilt functionality to search for items in other mailboxes, this functionality is called "Discovery Search". Take a look here: http://technet.microsoft.com/en-us/library/dd335072(v=exchg.141).aspx

    Hi Cameroon, its a requirement indeed to do this programatically. This would be a scheduled job which would clean-up emails (or move them) based on values of a custom MAPI property.

    "Discovery Search" seems very interesting. Is there a programmatic interface (scripting or anything) to this feature? Does it make any sort of web-service call (because if it does, we can always track the call using a proxy and initiate similar calls manually irrespective of whether the same is a documented or officially supported feature).

    Thanks a lot for this helpful tip!!


    I always think tomorrow will have more time than today. And every today seems to pass-by faster than yesterday.
    Rahul Singla | http://www.rahulsingla.com

    Tuesday, August 13, 2013 10:30 AM
  • It depends on the particular MAPI property you want to search and if that property is Indexed by Exchange Search you can see a full list of Indexed Properties on http://technet.microsoft.com/en-us/library/jj983804(v=exchg.150).aspx.  If the property you want to search for is indexed then in EWS you can use an AQS query and query every folder in a Mailbox. (or you could do a discovery search in EMS as somebody else has suggested using the AQS filter).

    In Exchange 2013 search has be significantly upgraded and if you have an Indexed property then you can use eDiscovery and a KQL query to search all folders in a Mailbox in one operation.

    If you have an unindexed property you going to have to in EWS uses a SearchFilter http://msdn.microsoft.com/en-us/library/dd633659(v=exchg.80).aspx  to query every folder or you may want to use MAPI using something like Redemption http://www.dimastr.com/redemption/mapitable.htm and use MAPITables. Each of these methods will require you to search every folder in the mailbox and depending on ItemCounts will take time.

    Cheers
    Glen

     

    Hi Glen, this is what we use to search the emails using EWS:

    new Exc.ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "FilingStatusCode", Exc.MapiPropertyType.Long)

    This is a custom MAPI property, and shouldn't be indexed. Is there a way to tell Exchange to index this property? We need to support Exchange 2010 upwards atleast, so 2013 specific extensions are a luxury we can't afford at this moment :)

    We basically need to create a job to clean emails from across mailboxes having a particular value for this MAPI property.


    I always think tomorrow will have more time than today. And every today seems to pass-by faster than yesterday.
    Rahul Singla | http://www.rahulsingla.com

    Tuesday, August 13, 2013 10:35 AM
  • >> . Is there a way to tell Exchange to index this property?

    Not as far as I know, because of the way the underlying custom properties get stored I don't think they support this.

    Is the FilingStatusCode a static value for the Items you want to delete if so you could create a SearchFolder that covers all the Folders in the Mailbox. This will let the Exchange Store handle the searches in the background and you can then just query the SearchFolder to delete the Items. If the value is Dynamic then a SearchFolder may not be that much help. You can corral the Items into one folder using a Exists SearchFolder eg only show the message in the Mailbox where your custom property is set.

    Cheers
    Glen 

    Wednesday, August 14, 2013 6:53 AM
  • Is the FilingStatusCode a static value for the Items you want to delete if so you could create a SearchFolder that covers all the Folders in the Mailbox.

    Cheers
    Glen 

    Hi Glen, that's great idea. Yes its a static value and hence we can create a Search Folder. I would be interested in knowing if Exchange provides any performance benefits to search folders (some kind of indexing support).

    I always think tomorrow will have more time than today. And every today seems to pass-by faster than yesterday.
    Rahul Singla | http://www.rahulsingla.com

    Wednesday, August 14, 2013 9:23 AM
  • From a client perspective Search folders will give you a performance benefit I'd suggest reading http://technet.microsoft.com/en-us/library/cc535025.aspx which covers the underlying details of Restricted Views (which are what search folders are). Search folders come at a cost on the server side so you don't want over use them but are probably the best fit for what you want to do.

    Cheers
    Glen

    Thursday, August 15, 2013 5:12 AM