Area 51

This started of as another one of those weird things. Well, so here goes.
Problem: Accessing the news listing through the Object Model.
Solution:
         // get the reference

           SPSite site = new SPSite(“https://localhost”); // this will point to the portal URL

           SPWeb web = site.OpenWeb();

          // get the context

           PortalContext context = PortalApplication.GetContext(site.ID); // context got using the site GUID

           Guid newsGuid = AreaManager.GetSystemAreaGuid(context, SystemArea.News);

           // SystemArea.News is a Sharepoint enumeration already available through the API
           Area newsarea = AreaManager.GetArea(context, newsGuid);

           AreaListingCollection newscoll = newsarea.Listings; // fetches all listings that are part of the current area

          

           for(uint i=0; i<newscoll.Count; i++)

           {

                 WriteToFile(newscoll[i].Title + “ “ + newscoll[i].Description); //WriteToFile is a custom function used for debug logging to a file

           }

And voila!

 

/Harsh