How to create an item in a discussion list

Creating a discussion in discussion list is different from creating a simple list item. The code for creating a discussion item is:

using (SPSite site = new SPSite(“SITE URL”))

{

using (SPWeb web = site.OpenWeb())

{

SPList list =web.Lists[“LIST TITLE”];

result = SPUtility.CreateNewDiscussion(list.Items, “SUBJECT”);

result[SPBuiltInFieldId.Body] = “BODY”;

result.Update();

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *