Monday, January 22, 2007

Delete all RSS Feeds folders in Outlook 2007

I made the mistake to import my OPML file into Microsoft Outlook 2007 and with several hundreds of feeds I found that there was no way to delete multiple feeds. (Outlook does not support OPML with folders.) So I used some of the sample code for Outlook as a starter and solved it quicker than having to delete them one by one. Here is how to remove them automatically saving the tedious work to remove them manually. Open the VBA IDE using Alt+F11 or Tools>Macro>Visual Basic Editor

In Project1>Microsoft Office Outlook Objects>ThisOutlookSession add this code and run the subroutine DeleteAllRssFeedsFolders (folder path might need to be changed). When deleted they end up in the Deleted Items folder where they easily can be permanently deleted.

Private Function GetFolder(ByVal FolderPath As String) As Outlook.folder
Dim TestFolder As Outlook.folder
Dim FoldersArray As Variant
Dim i As Integer

On Error GoTo GetFolder_Error
If Left(FolderPath, 2) = "\\" Then
FolderPath = Right(FolderPath, Len(FolderPath) - 2)
End If
'Convert folderpath to array
FoldersArray = Split(FolderPath, "\")
Set TestFolder = Application.Session.folders.Item(FoldersArray(0))
If Not TestFolder Is Nothing Then
For i = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.folders
Set SubFolders = TestFolder.folders
Set TestFolder = SubFolders.Item(FoldersArray(i))
If TestFolder Is Nothing Then
Set GetFolder = Nothing
End If
Next
End If
'Return the TestFolder
Set GetFolder = TestFolder
Exit Function

GetFolder_Error:
Set GetFolder = Nothing
Exit Function
End Function

Private Sub DeleteFolders(ByVal oFolder As Outlook.folder)
Dim folders As Outlook.folders
Dim folder As Outlook.folder
Dim foldercount As Integer

On Error Resume Next
Set folders = oFolder.folders
foldercount = folders.Count
If foldercount Then
For Each folder In folders
folder.Delete
DeleteFolders folder
Next
End If
End Sub

Sub DeleteAllRssFeedsFolders()
Dim folder As Outlook.folder
Set folder = GetFolder("\\Personal Folders In\RSS Feeds")
If Not (folder Is Nothing) Then
DeleteFolders folder
End If
End Sub

Part 2 of 3

Technorati tags: , ,

10 comments:

  1. Restored comment
    by JTB World
    Anonymous said that "it doesnt work. i changed the folder path"
    I deleted the comment due to bad language.

    ReplyDelete
  2. Restored comment
    by Anonymous
    Excellent couple of articles Jimmy, the code came in particularly useful for cleaning up my Outlook prior to moving to a "real" Feed Reader again.
    I too have used RSS Bandit in the past, but have recently moved to FeedDemon from Newsgator, now Free! and I tend to read my feeds from various PC's, and can access all my feeds using "Newsgator Online"

    Best Regards
    John Benstead
    http://cadit.typepad.com

    ReplyDelete
  3. I think this code saved me from carpal tunnel syndrome, as my opml had many hundreds of foldered blogs. I removed "In" from Set folder = GetFolder("\\Personal Folders In\RSS Feeds") to get mine to work.

    Thanks again

    ReplyDelete
  4. Thanks ,it saves lots of time. should never use outlook as an rss reader, specially if your rss feeder list is large.

    ReplyDelete
  5. Thanks for the code. Removed all folders in outlook which were created by IE7 Rss Feeds. Saved me loads of time.

    Ie7 should not modify outlook without user authorisation.

    ReplyDelete
  6. Super stuff! JTB thanks a bunch! You can't imagine how much time this saved!

    ReplyDelete
  7. Syed Abdul Karim, good to hear. I did the "mistake" myself and it was quicker to create this program than to solve it manually.

    ReplyDelete
  8. Another big thanks from me!!!

    ReplyDelete
  9. Thanks a million! This does work as long as you follow the instructions spot on.

    Thanks again

    ReplyDelete
  10. Kris, I use Outlook 2010 so not sure this apply to 2007 but in Account Settings on the RSS Feeds tab there is a Change Folder button.

    ReplyDelete

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Subscribe to this blog
JTB World's website | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.