How do i get a list of all e-mail address for exchange public folders?
Will reply on my own, will accept the best reply offered.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
While what you posted as your own answer would work, it helps to read the documentation for the methods and objects you are using to understand their limitations. If you had called this code multiple times you would eventually had a memory leak on your hands. The
foreachstatement doesn’t callDispose()on the object used, only the enumerator it creates. Below is a somewhat better method of searching the directory (though very little error checking and no exception handling).Note 1
The remarks for DirectorySearcher.SizeLimit indicate that the size limit is ignored if it is higher than the server-determined default (1000 entries). Paging allows you to get all of the entries you need as you need them.
Note 2
The remarks for DirectorySearcher.FindAll() mention that the SearchResultCollection needs to be disposed to release resources. Wrapping it in a
usingstatement clearly identifies your intent as a programmer.Extra
If you’re using Exchange 2007 or 2010 you could also install the Exchange Management Tools and use the powershell cmdlets to query your public folders. You can pragmatically create a powershell runspace and call the Exchange cmdlets directly without actually needing a console for the user to interact with.