Wednesday, 1 December 2010

Programmatically create Sharepoint 2010 Discussion Board thread

SPSite site = new SPSite("http://site:port");

SPWeb web = site.OpenWeb();

web.AllowUnsafeUpdates = true;

SPList discussionList = web.Lists["discussion board"];

SPListItem lstItm = SPUtility.CreateNewDiscussion(discussionList.Items, "My New Discussion");

lstItm[SPBuiltInFieldId.Body] = "This is the body of my new discussion";

lstItm.Update();

No comments:

Post a Comment