Export Office 365 mailbox contact list to CSV using EWS RRS feed

  • Question

  • I need to automate the process of pulling a .csv file containing data from the contact list in an Office 365 shared mailbox.

    We originally had on-premises Exchange 2010 and had a tool to pull the contents of a particular public contacts folder into our Shoretel directory so that all our company drivers' numbers were accessible for dialing within Shoretel without requiring each user to propagate all those contacts into their personal Outlook contacts and using MAPI to synch with Shoretel. Instead, all the numbers are simple available in our Shoretel directory.

    This all ran as a scheduled task that called a batch file. The batch file simple passed arguments to a Shoretel EXE that presumably called ExchangeWS API to extract data from the public contacts folder and create a .csv file with that data. The XML configuration file for that process should give some clue how they were using ExchangeWS, and a couple of Exchange DLLs sat in the same folder.

      <!-- Exchange Server version 0 for Echange server 2007 and 1 for 2010-->
      <!-- Required if not using network credentials-->
      <!-- Specify the path of Exchange Server-->
      <!--Public folder to fetch, specify relative path-->

    Once the Shoretel EXE used those parameters to extract the data and create the .csv file, then the batch file called a Shoretel process that imported the contents of that .csv file into the Shoretel directory.

    And then we moved to Office 365. In the process, public folders are no longer, and the data from the one we need now exists as the default contact list for a particular shared mailbox. So the data is still there, and the Shoretel import process can still import a properly-formatted CSV file. I just need to know how to use WS to get the data out of that shared mailbox contact list into a CSV file.

    Monday, September 21, 2020 7:59 AM

All replies

  • I would like to suggest you a solution that download contacts from Office 365 account into CSV file. The software is know as Office 365 Backup Tool, that supports to extract contacts from Office 365 into CSV file.


    Tuesday, September 22, 2020 8:05 AM
  • Can you confirm that this tool allow scripted automation of this process? I need a twice-daily export of that contact list that can be called from a batch file, since it must be immediately followed by an import to our Shoretel database. When I downloaded the trial version of that third-party tool, it seemed like it is a very manual process.

    And then it requires enabling IMAP in our Office 365 account. I am not sure how to do that, since I am not the primary administrator of the Office365 account.

    What I am looking for here is an ExchangeWS for Office365 programming guide, or at least confirmation that it is possible to do what I need to do using Exchange WS.

    Tuesday, September 22, 2020 7:38 PM
  • You can create a script to do this with EWS eg I've already done this with https://gsexdev.blogspot.com/2019/12/update-to-exchangecontacts-module-to.html the module published in the power-shellgallery https://www.powershellgallery.com/packages/ExchangeContacts/ so you can do 

    Export-EXCContacts -Folder "\Contacts" -MailboxName gscales@datarumble.com
     -ModernAuth -FileName c:\temp\exp.csv -ExportAsCSV

    you may need to customize the process a little by adding or removing fields you don't need. You can also do the same thing with the Microsoft Graph API


    Wednesday, September 23, 2020 12:29 AM