lördag 7 mars 2009

WSS Create Discussion Board item

Creating and manipulating ordinary lists in WSS through the object model is easy, and finding examples on the web is also easy. But what about discussion boards?

Turns out that they are not as easily manipulated, and examples are very hard to find. After much browsing I found this information though:
http://blogs.msdn.com/sfellman/archive/2007/12/17/issue-programmatically-posting-wss-2007-discussion-list-items-shows-sender-as-system-account-in-outlook-2007.aspx

Use this code:
using Microsoft.Sharepoint.Utilities;

SPListItem item = SPUtility.CreateNewDiscussion(.Items, "");
item["Body"] = "";
item.Update();

There is a corresponding method to add discussion replies:
SPUtility.CreateNewDiscussionReply(item);

Inga kommentarer:

Skicka en kommentar