locked
How to create a Blog using code in Sharepoint 2007 RRS feed

  • Question

  • Hi All,

      I have a requirement to create a Blog in Sharepoint 2007, how to create one using C# code. any help is appreciated.

    Thanks

     

     


    • Moved by Mike Walsh FIN Friday, April 29, 2011 6:45 AM Blog q so Social Computing (From:SharePoint - Development and Programming (pre-SharePoint 2010))
    • Edited by Gaby58 Friday, April 29, 2011 5:25 PM
    Friday, April 29, 2011 2:58 AM

Answers

  • Hi,

    Thanks to share your post.

    For the issue, please see the followed example code:

    protected void createSite()
    {
    string siteURL=”http://servername:port/site”;   Site URL
    string siteTitle=”TestSite”;                 // Site Title
    string sitedes=”Site for testing”;       //     Site Description
    int lcid=1033;                                   //  Local identifier – 1033 for English(US)
    string siteTemp=”BLOG#0″;     //Site Template “BLOG#0″-blog site

    SiteSPAdminService.Admin adminService=new SPAdminService.Admin();
    Authentication for default users crenntly logged in OS
    adminService.Credentials = CredentialCache.DefaultCredentials;
    Assigning authentication by code.  

    adminService.Credentials=new NetworkCredential(“UserName”,”Password”,”Domain”);
    try
    {
    adminService.CreateSite(siteURL, siteTitle , sitedes , lcid, siteTemp, “domainUserName”, “Display_UserName”, “email”, “”, “”);
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }

    And also see this article:

    http://msdn.microsoft.com/en-us/library/administration.admin.createsite.aspx.

    http://sharepointguys.com/brendon/sharepoint-2007/programming/create-mysites/.

    Hope this could help you!

    Leo

    • Marked as answer by Emir Liu Monday, May 9, 2011 9:47 AM
    Wednesday, May 4, 2011 7:07 AM

All replies

  • Hi Asha,

    Do you want to create blogs using Object Model or by using Out of Box blog functionality of SharePoint?

    You can start with:

     uint lcid = web.Language;

    SPWeb web2 = web.Webs.Add("Blog", "Blog", "Blog", lcid, web.GetAvailableWebTemplates(lcid)["BLOG#0"], false, false);


    ------------------------------------ Happy Workaround :) Vivek
    Friday, April 29, 2011 3:09 AM
  • Hi,

    Thanks to share your post.

    For the issue, please see the followed example code:

    protected void createSite()
    {
    string siteURL=”http://servername:port/site”;   Site URL
    string siteTitle=”TestSite”;                 // Site Title
    string sitedes=”Site for testing”;       //     Site Description
    int lcid=1033;                                   //  Local identifier – 1033 for English(US)
    string siteTemp=”BLOG#0″;     //Site Template “BLOG#0″-blog site

    SiteSPAdminService.Admin adminService=new SPAdminService.Admin();
    Authentication for default users crenntly logged in OS
    adminService.Credentials = CredentialCache.DefaultCredentials;
    Assigning authentication by code.  

    adminService.Credentials=new NetworkCredential(“UserName”,”Password”,”Domain”);
    try
    {
    adminService.CreateSite(siteURL, siteTitle , sitedes , lcid, siteTemp, “domainUserName”, “Display_UserName”, “email”, “”, “”);
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }

    And also see this article:

    http://msdn.microsoft.com/en-us/library/administration.admin.createsite.aspx.

    http://sharepointguys.com/brendon/sharepoint-2007/programming/create-mysites/.

    Hope this could help you!

    Leo

    • Marked as answer by Emir Liu Monday, May 9, 2011 9:47 AM
    Wednesday, May 4, 2011 7:07 AM