3 minute read

If you don’t know what RSS is, then you have been hiding under a pretty big rock lately. A lot of Microsoft’s products are currently out or are coming out in the next year use the Windows RSS platform. To name a few of these products off the top of my head are as follows: IE7, Office 2007, Windows Live Mail Desktop, and Windows Vista. I’m pretty sure that sometime in the next couple of years you will more than likely be working with RSS in one or more of your applications.

During the past week I have been working with the Windows RSS platform in one of my applications. My adventure into the unknown lands of the Windows RSS platform was quite an experience; I found out that the MSDN documentation tends to be very helpful, but real world examples tend to be a little scarce.

For that reason, I’ll show you how to easy it is to use the Windows RSS platform in your C# 2.0 Application to create an IE7 Feed in the root or subfolder of the Feeds Folder.

  1. Open Visual Studio 2005 and create a new Windows Application.

  2. Open the Solution Explorer and right click References and click “Add”.

  3. Switch to the COM tab and find “Microsoft Feeds, version 1.0”.

    RSS Add Reference

    You should now see Microsoft.Feeds.Interop in your References List.

  4. Add using Microsoft.Feeds.Interop; to the top of your Form1.cs

  5. Create a new method called AddIE7Feed that returns a Boolean and takes 3 String parameters (folder, URL, title). It should look like this:

    private bool AddIE7Feed(string folder, string url, string title) {
      return true;
    }
    
  6. Next lets add some code to AddIE7Feed.

    FeedsManager fm = new FeedsManager();
    IFeedFolder rootFolder = (IFeedFolder)fm.RootFolder;
    IFeedFolder subFolder = rootFolder;
    try {
      //if a folder path is supplied the following code is executed.
      if (folder != String.Empty) {
        //checks to see if the folder exists.
        if (!rootFolder.ExistsSubfolder(folder)) {
          //creates the folder if it does not exist.
          rootFolder.CreateSubfolder(folder);
          //set the subFolder to the new folder.
          subFolder = (IFeedFolder)rootFolder.GetSubfolder(folder);
        }
      }
    
      //checks to see if the feed exists (by checking the url and title).
      if (!subFolder.ExistsFeed(title) && !fm.IsSubscribed(url)) {
        //creates the feed if it does not exist.
        subFolder.CreateFeed(title, url);
        return true;
      }
    
      return false;
    } catch (Exception) {
      return false;
    }
    
  7. Lets add a feed by adding a few lines of code in the Form1_Load

    //Please note if the url to the feed already exists anywhere in the feeds folder an exception will occur.
    //Add a feed called "blakeniemyjski.com" to the root feeds folder.
    if (AddIE7Feed("", "https://blakeniemyjski.com/index.xml", "blakeniemyjski.com")) {
      MessageBox.Show("Feed was added successfully");
    } else {
      MessageBox.Show("Failed to add the Feed");
    }
    
    //close the application.
    this.Close();
    
  8. Run the application and then open IE7 and you should see the feed above.

    RSS Added feed to IE7

I know that this application does not have any User Interface it is purely meant to be an example on how to use the Windows RSS Platform with IE7.

I have compiled a list of links that I believe anyone working with the Windows RSS platform should read.

  1. Microsoft Team RSS Blog
  2. Windows RSS Platform Reference
  3. Using the Windows RSS Platform
  4. Valid Feed and Folder Names (Must Read)

To download the Visual Studio project and source follow the link below.

Working with the Windows RSS Platform Sample Application (C#)

Please note that the code in section six has been updated. In some circumstances if you only check if the feed exists by the name an exception will be thrown.

Join the mailing list

Get notified of new posts and related content to your inbox. I will never sell you anything and I will NEVER sell your email address.