How To Get all ITEMS from Folders and Sub-folders of PublicFolders Using EWS Managed API

To get all folders use the code below: public void GetAllFolders(ExchangeService service, List<Folder> completeListOfFolderIds) { FolderView folderView = new FolderView(int.MaxValue); FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, folderView); foreach (Folder folder in findFolderResults) { completeListOfFolderIds.Add(folder); FindAllSubFolders(service, folder.Id, completeListOfFolderIds); } } private void FindAllSubFolders(ExchangeService service, FolderId parentFolderId, List<Folder> completeListOfFolderIds) { //search for sub folders FolderView folderView = new FolderView(int.MaxValue); … Read more

Connection to Office 365 by EWS API

You can use the code below to connect to the EWS on office 365: ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1); service.Credentials = new WebCredentials(“[email protected]”, “password”); service.AutodiscoverUrl(“[email protected]”, RedirectionUrlValidationCallback); You need define one callback function for the AutodiscoveryUrl function, like this: private static bool RedirectionUrlValidationCallback(string redirectionUrl) { // The default for the validation callback is to reject the … Read more

How can I detect if this dictionary key exists in C#?

You can use ContainsKey: if (dict.ContainsKey(key)) { … } or TryGetValue: dict.TryGetValue(key, out value); Update: according to a comment the actual class here is not an IDictionary but a PhysicalAddressDictionary, so the methods are Contains and TryGetValue but they work in the same way. Example usage: PhysicalAddressEntry entry; PhysicalAddressKey key = c.PhysicalAddresses[PhysicalAddressKey.Home].Street; if (c.PhysicalAddresses.TryGetValue(key, out … Read more