I use Outlook 2007 as my feed reader. I have Outlook open all the time anyway in the Unread Mail folder, so this allows me to get blog posts along with email. I also want to have my blogroll on my blog and not have to maintain it in two places. There was not built-in mechanism in CS to do this, so I have built and released my first Community Server related tool to solve this problem.
Let's start at the top. Microsoft installs some nifty RSS stuff with IE7 called the Windows RSS Platform. You can find more info here and on Google. There is even an API screensaver sample in the Microsoft Download Center.
The Windows RSS Platform is what stores the feeds that Outlook shows me. With the API, it's very easy to get a list of feeds, etc.
The first step is to add a COM reference to Microsoft Feeds 1.0.
Then it is a simple matter of using the API. Below is sample Console code to retrieve the feeds on your system.
Imports Microsoft.Feeds.Interop
Module Module1
Sub Main()
Dim mgr As New FeedsManager
Dim root As IFeedFolder = CType(mgr.RootFolder, IFeedFolder)
For Each feed As IFeed In CType(root.Feeds, IFeedsEnum)
Console.WriteLine(feed.Url & " (" & feed.Path & ")")
Next
Console.WriteLine()
Console.WriteLine("Press any key to exit.")
Console.ReadKey()
End Sub
End Module
This should be pretty self explanatory. Check out MSDN for more properties available from the IFeed interface, such as the publication date and the last download time.
The next step proved to be a little harder. There is no remote Link service available within Community Server. So I built one called the Blogroll Service and modeled it after the existing BlogService web service. The Blogroll Service imports from two CS namespaces, CommunityServer.Components and CommunityServer.Blogs.Components and inherits from the CSWebServiceBase class. The cool thing about the base class is that it takes care of all the authentication and login stuff.
The other thing that was a little annoying is that the Links type does not provide the classes I would hope to find in a collection, such as FindByName or FindByUrl. It took a bunch of reflectoring to finally nail down how the pieces, CategoryId, SectionId and whatnot all fit together.
I ended up with an AddOrUpdateFeeds class.
<SoapHeader("Credentials"), WebMethod(Description:="Adds and updates the feeds on the blogroll.", EnableSession:=False)> _
Public Function AddOrUpdateFeeds(ByVal listName As String, ByVal feeds() As Feed) As Integer
MyBase.LoginSetSection()
Dim linkCategoryId As Integer = GetLinkCategory(listName)
' kind of a hack, but will do for now
' need to get some changes into the CS API to allow for better link mgmt
For Each item As Link In Links.GetLinks(linkCategoryId)
Links.DeleteLink(item.LinkID, item.LinkCategoryID)
Next
For Each feed As Feed In feeds
Dim link1 As Link = Me.GetLink(feed.Title, linkCategoryId)
link1.LinkCategoryID = linkCategoryId
link1.IsEnabled = True
link1.Title = feed.Title
link1.Url = feed.URL
link1.IsEnabled = True
link1.Description = String.Empty
link1.Rel = String.Empty
If (link1.LinkID > 0) Then
Links.UpdateLink(link1)
Else
Links.CreateLink(link1)
End If
Next
End Function
Rather than write all the code to handle delete detection, I just deleted all the links from the list, and added the supplied ones. It's a hack, and not pretty, but it's 1.0 and serves my purpose.
To use the program, first choose Tools >> Options, and enter your information.
Then click Upload feeds.
There are a couple of things I'd like to add into future versions:
- The ability to deselect feeds from the list being published.
- Delete detection
- Maybe build it as an Outlook 2007 add-in to monitor the Feeds API events and update in real time. Maybe would be better as a tray app or a windows service?
- Make it faster, the web service seems to take awhile to load in the new links.
- Get the actual blog URL instead of using the RSS url.
The binary and source bits can be had in the download section.