locked
C# EWS Search in multiple mailboxes using Exchange Admin account recommendation RRS feed

  • Question

  • I have been tasked to create a daily search in multiple user mailboxes for specific search criteria on our Exchange 2013 box and export a few fields (subject, date, etc.) related to search results into SQL so we can use them to massage data, serve it up to those users, etc.  I have successfully used C#/EWS to connect to Exchange and pull fields required for my email account (using both Windows credentials for current user and a manual login) but only with my account directly.  My questions is: what is most efficient way of creating one login "to rule them all" and use that to connect to each mailbox to run search or is it even possible?  Will I have to use logins for each user as I run search or can I somehow use the Exchange Admin Account and "find" the mailboxes and run the search criteria?  Any help/code examples/links would be greatly appreciated.  I am a C#/SQL developer who is very unfamiliar with Exchange so I apologize for any misspoken terms (please don't bash me too badly).

    Thanks in advance,

    John

    PS-If there is a more simple, efficient and free way to do the above, please let me know.

    Wednesday, August 19, 2015 12:37 AM

Answers

All replies

  • Re Authentication I would suggest EWS Impersonation is what your looking for see https://msdn.microsoft.com/en-us/library/office/dn722377(v=exchg.150).aspx

    With the Search if you need to search across the whole Mailbox then I would suggest you use eDiscovery https://msdn.microsoft.com/en-us/library/office/jj190897(v=exchg.150).aspx it allows you to search firstly across a whole mailbox and multiple mailboxes the fields you mentioned are returned in the PreviewItem. Otherwise with EWS you would need to search one folder at a time which will achieve the same thing but will be slower. (With eDiscovery you need to make sure the account making the search is assigned the correct RBAC role https://technet.microsoft.com/en-us/library/dd298059%28v=exchg.150%29.aspx )

    Cheers
    Glen

    • Marked as answer by jlaponsie Wednesday, August 19, 2015 3:04 PM
    Wednesday, August 19, 2015 2:46 AM
  • You have mention that " I have successfully used C#/EWS to connect to Exchange and pull fields required for my email account (using both Windows credentials for current user and a manual login) but only with my account directly. " I also need help on this. Please let me know how you accompolished data extraction using your credential?

    Wednesday, August 19, 2015 10:50 AM
  • Rohit,

    Did you get this resolved yet? Can you send me a link to your post so I can look at your code to see the differences?  I'm not sure if I can help using the best practices, but I can send you how I accomplished this.

    -JL

     

    Wednesday, August 19, 2015 2:17 PM