Tags: | Categories: Sharepoint Posted on 6/1/2008 11:22 PM | Comments (0)

sharepointFollowing my series of retrieving HTML from SharePoint - I had to recently retrieve the HTML from the Blog post in SharePoint.

 

One again - it is pretty straight forward but as the Blogs are a different site compared to SharePoint MySite - you will need to develop a feature at a Site Collection level.

 

 
public bool Convert(string ItemId, string SiteUrl)
{
    //Get Site, Web, List and Retrieve ListItem
    using (SPSite Site = new SPSite(SiteUrl))
    {
        using (SPWeb Web = Site.OpenWeb())
        {
            SPList List = Web.Lists["Posts"];
            SPListItem ListItem = List.GetItemById((Int32.Parse(ItemId)));
            HTML = String.Format("<html><body>{0}</body></html>", 
                   ListItem["Body"].ToString());
        }
    }
}

The list you are retrieving data from here is "Posts".

Comments are closed