Delete All Outlook RSS Feeds

My Outlook RSS Feeds were in a really funky state this morning. I had to create a new profile and I had RSS Sync enabled. When that is the case Outlook re-adds all Feeds that you have ever added to the machine back into your profile even if you previously deleted them using the Outlook UI.
After many failed attempts to fix this with the help of a few folks internally I decided to write a quick script to delete all RSS feeds in Outlook.
I first try to delete and if that fails I move the folder to the Deleted Items folder. (The delete was failing for me for some unobvious permission issue).
This was the exception:

Cannot delete this folder. Right-click the folder, and then click Properties to check your permissions for the folder. See the folder owner or your administrator to change your permissions. You don’t have appropriate permission to perform this operation.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Outlook;
namespace OutlookRssDelete {
class Program {
static void Main(string[] args) {
Application app = new Application();
NameSpace ns = app.GetNamespace("MAPI");
MAPIFolder feeds = ns.GetDefaultFolder(OlDefaultFolders.olFolderRssFeeds);
MAPIFolder delitems = ns.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems);
// Put in temp because we need to delete from the same list
List feedFolders = new List();
foreach(MAPIFolder f in feeds.Folders) {
feedFolders.Add(f);
}
foreach(MAPIFolder f in feedFolders) {
Console.WriteLine(f.Name);
try {
f.Delete();
} catch {
try {
Console.WriteLine("Delete failed.Try Moving to Deleted Items");
f.MoveTo(delitems);
} catch (System.Exception ex1) {
Console.WriteLine("Move to Deleted Items Failed.Call Helpdesk: )" + ex1.ToString());
}
}
}
}
}
}
Share