Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

How to add contacts to All Contacts in directories

$
0
0

Hi,

     I are trying to add contacts and want to show it on all contacts folder in left navigation directory panel. I have used the following code.

try
            {
                ExchangeService Exchageser = new ExchangeService(ExchangeVersion.Exchange2010);
                Exchageser.Credentials = new WebCredentials("administrator", "test", "testtestdomian.in");
                //Exchageser.AutodiscoverUrl("cgvak@minasu.amsoftonline.net");
                Exchageser.Url = new Uri("https://test-exhsvr/ews/exchange.asmx");

                //#endregion
                //Folder rootfolder = Folder.Bind(Exchageser, "Directory");
                FolderView view = new FolderView(100);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.Traversal = FolderTraversal.Deep;
                FindFoldersResults findFolderResults = Exchageser.FindFolders(WellKnownFolderName.Contacts, view);
                //find specific folder
                foreach (Folder f in findFolderResults)
                {
                    if (f.DisplayName == "GAL Contacts")
                    {
                        FolderId fID = f.Id;

                        Contact objCreatecontact = new Contact(Exchageser);
                        objCreatecontact.GivenName = firstname;
                        objCreatecontact.Surname = lastname;
                        objCreatecontact.EmailAddresses[EmailAddressKey.EmailAddress1] = new EmailAddress("Ra@testdomian.in");

                        objCreatecontact.Save(fID);
                    }
                }

            }
            catch(Exception ex)
            {
                return ex.ToString();
            }

But the above code helps me to add contact to the specific user. Kindly, let me know is there any possibilities to show the contacts in all contacts folder in left navigation.

Thanks..


Viewing all articles
Browse latest Browse all 7132

Trending Articles