none
[C#][EWS-managed-API 2.2][WPF][Exchange Server 2013] synchronize GAL to Application RRS feed

  • Question

  • Hello i try to create a application that synchronize and shows every contact in the GAL to an User-Interface so i can pase it to my custom contacts class. Somehow it wont work. For my Local Adress List it works but when it comes from an GAL it wont work. So when there is any way around i didnt found it.

    What i tried so far: (For the local contacts (works))

     private void AsignValuetoClass(object sender, RoutedEventArgs e)
            {
    
                //For the connection
                es.UseDefaultCredentials = true;
                es.AutodiscoverUrl("max.mustermann@muster.at", RedirectionUrlValidationCallback);
    
                //How many Contacts are in the folder
                ContactsFolder contactsfolder = ContactsFolder.Bind(es, WellKnownFolderName.Contacts);
    
    
    
                //To get a specific number of contacts
                int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50;
    
                //object of the Itemview
                ItemView view = new ItemView(numItems);
    
                //return the stuff
                FindItemsResults<Item> contactIds = es.FindItems(WellKnownFolderName.Contacts, view);
    
    
    
    
                //loop throug the item
                foreach (Item item in contactIds)
                {
    
                    if (item is Contact)
                    {
                        //assign of the contact items
                        Contact contact = item as Contact;
    
                        //new list
                        List<Contact> testlist = new List<Contact>();
                        //Add the contacts
                        testlist.Add(contact);
    
                        //loop through contact list 
                        foreach (Contact Liste in testlist)
                        {
                            //new object on every run
                            TestKlasse test = new TestKlasse();
    
                            //assign
                            test.id = Convert.ToString(contact.Id);
                            test.Vorname = contact.GivenName;
                            test.Nachname = contact.Surname;
                        }
    
                        Console.WriteLine("Some stupid Text");
    
                    }
                }
            }

    The for the GAL: (dont work)

           private void SearchContacts(object sender, EventArgs e)
            {
    
                //For the connection
                es.UseDefaultCredentials = true;
                es.AutodiscoverUrl("max.mustermann@muster.at", RedirectionUrlValidationCallback);
    
    
                // Identify the mailbox folders to search for potential name resolution matches.
                List<FolderId> folders = new List<FolderId>() { new FolderId(WellKnownFolderName.Contacts) };
    
                // Search for all contact entries in the default mailbox contacts folder and in Active Directory Domain Services (AD DS). This results in a call to EWS.
                NameResolutionCollection coll = es.ResolveName("WEB Kontakte Gesamt", folders, ResolveNameSearchLocation.DirectoryOnly, false);
                NameResolutionCollection colle = es.ResolveName("B", folders, ResolveNameSearchLocation.DirectoryOnly, false);
                NameResolutionCollection collec = es.ResolveName("C", folders, ResolveNameSearchLocation.DirectoryOnly, false);
                
    
                foreach (NameResolution nameRes in coll)
                {
                    Console.WriteLine("Contact name: " + nameRes.Mailbox.Name);
                    Console.WriteLine("Contact e-mail address: " + nameRes.Mailbox.Address);
                    Console.WriteLine("Mailbox type: " + nameRes.Mailbox.MailboxType);
                }
    
                foreach (NameResolution nameRes in colle)
                {
                    Console.WriteLine("Contact name: " + nameRes.Mailbox.Name);
                    Console.WriteLine("Contact e-mail address: " + nameRes.Mailbox.Address);
                    Console.WriteLine("Mailbox type: " + nameRes.Mailbox.MailboxType);
                }
    
                foreach (NameResolution nameRes in collec)
                {
                    Console.WriteLine("Contact name: " + nameRes.Mailbox.Name);
                    Console.WriteLine("Contact e-mail address: " + nameRes.Mailbox.Address);
                    Console.WriteLine("Mailbox type: " + nameRes.Mailbox.MailboxType);
                }
    
    
    
            }
    And many hours of google but no success. So any help would be great. Thx for your time and sorry for my bad english.

    Monday, February 22, 2016 11:01 AM