How to: Subscribe to an RSS Feed

This example shows how to subscribe to an RSS feed by using the OpenSharedFolder(String, Object, Object, Object) method.

Programming Applications for Office Outlook 2007

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).

Buy this book

Sample chapters

The Outlook object model supports providing access to shared data, such as Internet calendars, RSS feeds, and data from Microsoft SharePoint lists and document libraries. It enables connecting to these shared sources of data and setting up the synchronization contexts to continue to poll those shared resources. The Outlook object model provides the OpenSharedFolder(String, Object, Object, Object) method of the NameSpace object to download and synchronize with a particular type of shared folder.

In the following example, AddRssFeed subscribes to a new RSS feed named “Example RSS Feed” by calling the OpenSharedFolder method with a URL that refers to the new RSS feed. The last two parameters of OpenSharedFolder method are set to true to indicate that attachments should be downloaded, and Outlook should use the refresh ratio provided in the RSS feed.

Note Note

You must specify the correct protocol handler for the folder URL in the OpenSharedFolder method to subscribe to an RSS feed. For example, you must use a URL that begins with feed:// instead of http://. Outlook cannot open RSS feeds that require authentication unless Windows NT LAN Manager (NTLM) authentication is available, and it cannot load RSS feeds from Secure Sockets Layer (SSL) locations.

If you use Microsoft Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 14.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void AddRssFeed()
    string feedUrl = "feed://";
    Outlook.Folder subscriptionFolder =
        Application.Session.OpenSharedFolder(feedUrl, "Example RSS Feed", true, true) as Outlook.Folder;
    Outlook.Explorer exp =
        Application.Explorers.Add(subscriptionFolder, Outlook.OlFolderDisplayMode.olFolderDisplayNormal);

Other Resources