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

Please enter your comment!
Please enter your name here