I'm trying to create a C# script that will allow me to import blog posts from a different system (exported as CSV) into a SharePoint blog. I have found a script for comments to a blog post, but I'm having trouble finding the write fields/syntax for posts themselves.
public static void AddComment(string url)
{
using (SPSite site = new SPSite(url))
{
site.AllowUnsafeUpdates = true;
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList commentList = web.Lists["Comments"];
SPListItem newItem = commentList.AddItem();
newItem["Body"] = "body";
newItem["Title"] = "title";
newItem["PostTitle"] = "2;#post1";
newItem.Update();
}
}
}
From the above code for adding comments, I see that it's a simple SPListItem
. Plus, it appears that the link between comments and posts is the PostTitle
, but in this example is 2;#post1
pointing to post with ID=2, or does that post have a title of "2" (i.e. would `PostTitle = "My Title;#post 4" work, where my post has the title "My Title" and this particular comment is the 4th one?
Any links/code/advice would be appreciated.
Kevin