none
grab a distribution list in the public folders using EWS RRS feed

  • Question

  • I work in a small office that has an Exchange 2013 server.  We would like to be able (vb or C# code would be great) query a distribution list called ListA from the public folders/Office Contacts. So under public folders there is another folder called Office Contacts. In that office contacts is where ListA distribution list lives. We want to get a listing of all the contacts that belong to that ListA. We would like to use EWS to do this as the results will be displayed to an internal web page. I've tried like crazy to figure out how to do this but have not had any luck getting any further than the Office Contacts. Can someone please point me in the right direction. I've got EWS 2.0 on the web project. I would post code but i'm not sure what I have would be of any value.

    Thanks

    Shannon

    Thursday, July 23, 2015 6:19 PM

Answers

  • It should be relatively simple, Distribution Lists are stored in Contact Folders aren't called DL's they are called Contact Groups. So all you need to do is Find the Folder first, Find the list (search by name), Load the Members and enumerate eg

                //Get Public Folder
                SearchFilter sf = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Office Contacts");
                FindFoldersResults rrRes =  service.FindFolders(WellKnownFolderName.PublicFoldersRoot, sf, new FolderView(1));
                Folder OfficeContacts = rrRes.Folders[0];
                //Find the Distribution List
                SearchFilter dlSearch = new SearchFilter.IsEqualTo(ContactGroupSchema.DisplayName, "My List");
                ItemView ivItemView = new ItemView(1);
                FindItemsResults<Item> fiResults = OfficeContacts.FindItems(dlSearch, ivItemView);
                if (fiResults.Items.Count == 1) { 
                    //Enumeate Members
                    ContactGroup cg = (ContactGroup)fiResults.Items[0];
                    cg.Load();
                    foreach (GroupMember gm in cg.Members) {
                        Console.WriteLine(gm.AddressInformation.Address);
                    }
                }
    Cheers
    Glen

    • Marked as answer by jvcoach23 Friday, July 24, 2015 2:55 PM
    Friday, July 24, 2015 1:35 AM