How to get list of active/accesible or impersonated mailboxes from office365 by logging in as admin


I’m writing the given code to access impersonated mailboxes using admin account. please help me how can I get active/accessible or impersonated mailboxes from Office 365 or Exchange Server by logging in as admin.

NetworkCredential credential = new NetworkCredential(username, password, domain);

                client = EWSClient.GetEWSClient(mailboxUri, credential);
               ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
                MessageBox.Show("Total Users: " + distributionLists.Count());
                foreach (ExchangeDistributionList distributionList in distributionLists)
                    MailAddressCollection members = client.FetchDistributionList(distributionList);
                    foreach(MailAddress member in members)




I have observed your requirements and like to share that the requirement is already under investigation in our issue tracking system with ID EMAILNET-39546. This thread has been linked with the issue once the shared issue will be resolved.