Outlook Script Delete RSS Feeds

I have seen articles to use GPO to manage new subscriptions to RSS feeds.  I also know how to stop current local subscriptions by using the "/cleansharing" cmd line switch.  However, I have a problem with current feeds that users have downloaded.  These are quite large as they have been synching the common feeds for ages.

Is there a way, or does someone have a script, to remove existing downloaded RSS items from a users Outlook?

We do not have roaming profiles, so I presume it would have to run on either Outlook or windows startup, or possibly against Exchange itself?

thanks.
Brian_LimerickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shreedhar EtteCommented:
David LeeCommented:
Hi, Brian_Limerick.

The code below should delete all the items in all the RSS feed folders in Outlook.  I say "should" because I haven't tested it.  Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Run the macro
Sub DeleteRSSFeedItems()
    Dim olkFolder As Outlook.Folder, olkSubfolder As Outlook.Folder, olkItem As Object, intIndex As Integer
    Set olkFolder = Session.GetDefaultFolder(olFolderRssFeeds)
    For Each olkSubfolder In olkFolder.Folders
        For intIndex = olkSubfolder.Items.count To 1 Step -1
            Set olkItem = olkFolder.Items.Item(intIndex)
            olkItem.Delete
        Next
    Next
    Set olkItem = Nothing
    Set olkSubfolder = Nothing
    Set olkFolder = Nothing
End Sub

Open in new window

Brian_LimerickAuthor Commented:
Hi shreedhar,

This looks like the business and you were first up, but I'm not the best at c#, how would I bundle that so I could run it from dos on windows startup?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Brian_LimerickAuthor Commented:
increasing points
David LeeCommented:
I posted a working solution.  Have you tried it?
Brian_LimerickAuthor Commented:
Hi Bluedevilfan. I can see how your solution would work for an individual running it. But how can I implement it against all the users in my organization? Can a macro be run on startup? I'm just a bit unclear how to deploy it.

Thanks. B
David LeeCommented:
Does your organization use a logon script, or can you use a logon script?  If "yes", then I can modify that code to run from outside of Outlook.  You'd add the code to your existing logon script, or set it to be run at logon.  The next time the employee logs on the script would run.
Brian_LimerickAuthor Commented:
that would great, if you wouldn't mind.  
thanks,B
David LeeCommented:
This should do it.  Follow these instructions to use this.

1.  Open Notepad.
2.  Copy the code below and paste it into Notepad.
3.  Edit the code as needed.  I included comments where things can/must change.
4.  Save the file with a .vbs extension.
Const olFolderRssFeeds = 25
Dim olkApp, olkSes, olkFld, olkSub, olkItm, intIdx
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
'Change the profile name on the next line'
olkSes.Logon "Outlook"
Set olkFld = olkSes.GetDefaultFolder(olFolderRssFeeds)
For Each olkSub In olkFld.Folders
    For intIdx = olkSub.Items.count To 1 Step -1
        Set olkItm = olkFld.Items.Item(intIdx)
        olkItm.Delete
    Next
Next
Set olkItm = Nothing
Set olkSub = Nothing
Set olkFld = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brian_LimerickAuthor Commented:
Hi BlueDevilFan,
Sorry for the delay.  We are in the process of testing this script.  we will try to get back asap.
Brian_LimerickAuthor Commented:
Hi BlueDevilFan,

Just got back to this now.  There was an indexing bug in you code, perhaps because my rss feeds are tied to Sharepoint? who knows?  anyway I adapted the code to delete at the folder level and it seems to work.  

Delete is commented out in this example for testing.
Const olFolderRssFeeds = 25
Dim olkApp, olkSes, olkFld, olkSub, intIdx, intCount

Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
'Change the profile name on the next line'
olkSes.Logon "Outlook"

Set olkFld = olkSes.GetDefaultFolder(olFolderRssFeeds)
Wscript.echo(olkFld) 

intCount = olkFld.Folders.count
Wscript.echo("Folder Count: " & intCount) 

For intIdx = intcount to 1 step -1
   Set olkSub = olkFld.Folders.item(intIdx)
   Wscript.echo("Feed Name: " & olkSub) 
   'olkSub.Delete
Next

Set olkSub = Nothing
Set olkFld = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing

Open in new window

David LeeCommented:
Ok.  Glad you got it worked out.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.