public static Folder FindPublicFolderByName(ExchangeService svc, string folderName) { FolderView folderView = new FolderView(int.MaxValue); FindFoldersResults findFoldersResults = svc.FindFolders(WellKnownFolderName.PublicFoldersRoot, folderView); foreach (var folder in findFoldersResults) { if (folderName.Equals(folder.DisplayName, StringComparison.InvariantCultureIgnoreCase)) { return folder; } else if (folder.ChildFolderCount > 0) { Folder f = FindFolderByNameRecursive(svc, folder, folderName); if (f != null) return f; } } throw new Exception("Folder Not Found: " + folderName); } private static Folder FindFolderByNameRecursive(ExchangeService s, Folder f, string folderName) { FolderView folderView = new FolderView(int.MaxValue); FindFoldersResults findFoldersResults = s.FindFolders(f.Id, folderView); foreach (Folder folder in findFoldersResults) { if (folderName.Equals(folder.DisplayName, StringComparison.InvariantCultureIgnoreCase)) { return folder; } else if (folder.ChildFolderCount > 0) { Folder f2 = FindFolderByNameRecursive(s, folder, folderName); if (f2 != null) return f2; } } return null; }
Monday, 21 April 2014
Insert Email into Exchange Public Folder - Searching (1 of 2)
Here is a method that will enable you to search for a Public Folder In Exchange. It returns a 'Folder' object which we can use to insert objects to. We Need however to specify a 'Root' Folder as well as the 'ExchangeServiceBinding' object.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment