top of page

Programmatically Configure RSS Settings For a List


Introduction:

Really Simple Syndication (RSS) is used for transmitting information across the internet and intranets. We can also subscribe to RSS Feeds from SharePoint libraries, lists, and other elements. We can use an RSS Viewer Web Part to display an RSS Feed on a SharePoint site. An RSS Viewer Web Part provides a convenient way to view information from many sources on a single page.

In this article we will be seeing how to programmatically configure RSS settings for the SharePoint list.

Configure RSS settings for the list:

  • Go to the SharePoint List => List Settings => Communication => RSS settings.






  • Open Visual Studio 2010.

  • Go to File => New => Project.

  • Select Console Application template from the installed templates.

  • Add the following references.

i) Microsoft.SharePoint

  • Add the following namespaces.

i) using Microsoft.SharePoint;

  • Replace Program.cs with the following code.

  1. using System;

  2. using System.Collections.Generic;

  3. using System.Linq;

  4. using System.Text;

  5. using Microsoft.SharePoint;

  6. namespace RSSSettings

  7. {

  8. class Program   

  9. {

  10. static void Main(string[] args)       

  11. {

  12. using (SPSite site = new SPSite("http://serverName:1111/sites/Sample/"))           

  13. {

  14. using (SPWeb web = site.RootWeb)               

  15. {

  16. SPList list = web.Lists.TryGetList("Contributor");

  17. if (list != null)                   

  18. {

  19. //Configure RSS settings                    

  20. }

  21. else                   

  22. {

  23. Console.WriteLine(list.Title + " does not exists in the site");                   

  24. }

  25. Console.ReadLine();               

  26. }           

  27. }        

  28. }   

  29. }

  30. }

//Enable RSS settings







list.EnableSyndication = true;

list.Update();

// Truncate multi-line text fields to 256 characters   





list.RootFolder.Properties["vti_rss_LimitDescriptionLength"] = 1;

// Title





list.RootFolder.Properties["vti_rss_ChannelTitle"] = "Contributor List RSS";

// Description





list.RootFolder.Properties["vti_rss_ChannelDescription"] = "RSS feed for Contributor List";

// Image URL






list.RootFolder.Properties["vti_rss_ChannelImageUrl"] ="/sites/Sample/_layouts/images/siteIcon.png";

// Maximum items to include






list.RootFolder.Properties["vti_rss_ItemLimit"] = 15;

// Maximum days to include







list.RootFolder.Properties["vti_rss_DayLimit"] = 3;

list.RootFolder.Update();

// For Document Library

// Include file enclosures for items in the feed?








list.RootFolder.Properties["vti_rss_DocumentAsEnclosure"] = 0;

// Link RSS items directly to their files?

list.RootFolder.Properties["vti_rss_DocumentAsLink"] = 0;

0 comments

Comments


bottom of page