Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 431983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:01:45+00:00 2026-05-12T20:01:45+00:00

How do i get a list of all e-mail address for exchange public folders?

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:01:45+00:00Added an answer on May 12, 2026 at 8:01 pm

    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 foreach statement doesn’t call Dispose() 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).

    public static void GetPublicFolderList()
    {
        DirectoryEntry entry = new DirectoryEntry("LDAP://sorcogruppen.no");
        DirectorySearcher mySearcher = new DirectorySearcher(entry);
        mySearcher.Filter = "(&(objectClass=publicfolder))";
        // Request the mail attribute only to reduce the ammount of traffic
        // between a DC and the application.
        mySearcher.PropertiesToLoad.Add("mail");
    
        // See Note 1
        //mySearcher.SizeLimit = int.MaxValue;
    
        // No point in requesting all of them at once, it'll page through
        // all of them for you.
        mySearcher.PageSize = 100;
    
        // Wrap in a using so the object gets disposed properly.
        // (See Note 2)
        using (SearchResultCollection searchResults = mySearcher.FindAll())
        {
            foreach (SearchResult resEnt in searchResults)
            {
                // Make sure the mail attribute is provided and that there
                // is actually data provided.
                if (resEnt.Properties["mail"] != null
                     && resEnt.Properties["mail"].Count > 0)
                {
                    string email = resEnt.Properties["mail"][0] as string;
                    if (!String.IsNullOrEmpty(email))
                    {
                        // Do something with the email address
                        // for the public folder.
                    }
                }
            }
        }
    }
    

    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 using statement 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to get all members (mail address) of a certain distribution list.
How do you get all unread mail in a users' exchange mailbox using PHP
i want to get list of all application or Threads attached with a process.For
How can I to get list of all wcf services running on a machine?
Trying to get a list of all substrings currently I have a function but
I want to get a list of all TRs that do not include THs.
I want to get the list of all the bills for which a particular
I need a get a list of all databases in a Couchdb server inside
How can i get a list of all changes from TFS that were in
How do you get a list of all the tables and use that list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.