Kirk Evans Blog

.NET From a Markup Perspective

Working with the Common Feed Store in Windows

@kaevans

Working with the Common Feed Store in Windows

  • Comments 1

I have been trying to find a way to write an addin or utility to make the RSS support in Outlook suck a little less.  Outlook has support for OPML import, but it flattens the hierarchy in the OMPL file.  For instance, here’s a very small sample of my OPML. 

<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
  <head />
  <body>
    <outline text="SharePoint">
      <outline text="Andrew Connell [MVP MOSS]" xmlUrl="http://feeds.feedburner.com/AndrewConnell" />
      <outline text="Dan Attis" xmlUrl="http://feeds.feedburner.com/Attis" />
      <outline text="harbar.net" xmlUrl="http://feeds.feedburner.com/Harbar" />
      <outline text="Jan Tielens' Bloggings" xmlUrl="http://weblogs.asp.net/Jan/Rss.aspx" />
      <outline text="Jeremy Thake" xmlUrl="http://feeds.feedburner.com/Made4thenet" />
      <outline text="Sahil Malik" xmlUrl="http://feeds.feedburner.com/winsmarts" />
      <outline text="Scot Hillier" xmlUrl="http://scothillier.spaces.live.com/feed.rss" />
      <outline text="Sharepoint BUZZ" xmlUrl="http://feeds.feedburner.com/SharepointBuzz" />
    </outline>
    <outline text="Live Platform and Cloud">
      <outline text="Angus Logan" xmlUrl="http://blogs.msdn.com/angus_logan/rss.xml" />
      <outline text="Live Mesh" xmlUrl="http://blogs.msdn.com/livemesh/rss.xml" />
      <outline text="David Chappell :: Weblog" xmlUrl="http://www.davidchappell.com/blog/atom.xml" />
      <outline text="Windows Azure" xmlUrl="http://blogs.msdn.com/windowsazure/rss.xml" />
    </outline>
    <outline text="Silverlight and CLR">
      <outline text="Brad Abrams" xmlUrl="http://blogs.msdn.com/brada/rss.xml" />
      <outline text="Jason Zander's WebLog" xmlUrl="http://blogs.msdn.com/jasonz/rss.xml" />
      <outline text="Jesse Liberty - Silverlight Geek" xmlUrl="http://feeds.feedburner.com/JesseLiberty-SilverlightGeek" />
      <outline text="Method ~ of ~ failed" xmlUrl="http://feeds.feedburner.com/timheuer" />
    </outline>
    <outline text="Videos">
      <outline text="Channel 9: The Videos" xmlUrl="http://beta.channel9.msdn.com/Media/Videos/feed/wmv/" />
      <outline text="Channel 9: Screencasts" xmlUrl="http://channel9.msdn.com/Media/Screencasts/rss/Default.aspx" />
    </outline>
  </body>
</opml>

In Outlook, you can import this OPML into Outlook really easily by going to the “File / Import and Export…” menu and importing an OPML file.

image

Once you choose an OPML file, you get a dialog like this asking which feeds you want to import.

image

That creates the following structure.

image

Argh.  OK, you can kind of work around this by creating a new folder and then manually moving the existing folder.  But then that highlights another problem with the RSS in Outlook… when I use subfolders, I can’t see that there are unread items beneath that folder unless I expand each folder.  When I click on the SharePoint node, it would be nice if I could see all the feeds that are children of that folder in the list view, but it doesn’t work like that (for the record, email doesn’t work like that, either… if you have child folders under your Inbox, you don’t see those child folders in the Inbox list view). 

image

What I came to realize is that I want Outlook to work very differently than how it is currently implemented.  That’s when you either fire up Visual Studio or purchase a product from someone that’s already done the work for you.  Either I need to do a bit of work with VSTO or C++ to write a custom implementation or give up and just buy NewsGator which already does what I am asking.

My buddy Andrew Coates came up with an interesting possible solution:  Use the Common Feed Store.  Since I was programming an Outlook add-in, I quickly put this code together to test the theory.  All I had to do was add a reference to Microsoft.Feeds.Interop (found on the COM tab) and use the following code to programmatically add to the Common Feed Store.

        void ImportOpml()
        {
            //Prompt for OMPL file             
            System.Windows.Forms.OpenFileDialog openDialog = 
                new System.Windows.Forms.OpenFileDialog();
            openDialog.Filter = "OPML files|*.opml";
            openDialog.Title = "Open OPML file";
            openDialog.ShowDialog();
            if (openDialog.FileName.Length > 0)
            {
                FeedsManager fm = new FeedsManagerClass();
                IFeedFolder folder = (IFeedFolder)fm.RootFolder;

                foreach (var outline in XDocument.Load(openDialog.FileName).Element("opml").Element("body").Elements("outline"))
                {
                    AddRSSFeed(outline, folder);
                }                
            }
        }

        private void AddRSSFeed(XElement outline, IFeedFolder folder)
        {
            if(outline.Attributes("xmlUrl").Count() > 0)
            {
                //This is a feed with a URL
                string SName = outline.Attribute("text").Value;
                string SURL = outline.Attribute("xmlUrl").Value;
                
                IFeed feed = (IFeed)folder.CreateFeed(SName, SURL);
            }
            else
            {
                //This is a folder with only a name
                IFeedFolder childFolder = (IFeedFolder)folder.CreateSubfolder(outline.Attribute("text").Value);
                
                foreach (var child in outline.Elements("outline"))
                {
                    AddRSSFeed(child, childFolder);
                }
            }
        }

That was scary easy, and the feeds show up in IE8 right away.

The result of the above routine did, in fact, add the feeds to the Common Feed Store, which then shows up in my feeds in IE8.  Then I went into Outlook (Tools / Options / Other / Advanced) and enabled synchronization between the Common Feed Store and Outlook.

image 

What I was hoping for Outlook to honor the folder hierarchy if it used the Common Feed Store synchronization, but alas it still flattens the hierarchy as shown above. 

Since I can’t find a simple solution to make Outlook honor my intended hierarchy, I decided to take another look at using IE for reading RSS feeds. 

image

Notice that it preserves the hierarchy, which was one of my goals.  I also like the Filter By Category functionality on the right to quickly filter the items on the current page.  The search functionality is also nice, allowing me to go to Scott Guthrie’s blog and enter “MVC” to find references to MVC in the past 10 posts. 

Since I can’t seem to find a way to make Outlook do what I want (oh, I’m sure there’s some way I can programmatically do this in Outlook using C++, but the amount of effort required has far surpassed both my interest level and attention span), it looks like I am going to be using IE as a feed reader for the near future.  I don’t want to use another program like RSS Bandit, I like having the feeds integrated into a program that I constantly use.  Outlook would have been my first choice, but maybe I can get used to IE for this feature.

The Common Feed Store is a really good idea, allowing you to provide a common repository for feeds that multiple applications can utilize.  I like the idea of being able to subscribe to a feed quickly in IE and then have that feed show up in another application.  I really like not having to maintain an OPML file, which I mainly used to export from one program and import to another as I keep searching for just the right feed reader for me.

Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post
Translate This Page
Search
Archive
Archives