Macro - Mark All Outlook Folders (including RSS items) As Read

blashmet

New Member
Joined
Dec 15, 2015
Messages
1
In order to mark all items in my inbox and subfolders as read, I edited some macros posted here (http://www.mrexcel.com/forum/genera...884-outlook-macro-mark-folder-items-read.html).

This is the full macro:

Code:
Sub MarkAllRead()


Dim ResultFolder As Folder
Dim Folder As Folder
Dim item As MailItem
Dim BaseFolder As Outlook.MAPIFolder
Dim WalkResult As Long
Dim objInbox As Outlook.MAPIFolder
Dim objOutlook As Object, objnSpace As Object, objMessage As Object
Dim objSubfolder As Outlook.MAPIFolder




Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")
Set BaseFolder = objnSpace.GetDefaultFolder(olFolderInbox)
Set ResultFolder = GetFolder(BaseFolder.FolderPath)






For Each item In BaseFolder.Items.Restrict("[unread] = true")
item.UnRead = False
Next






For Each Folder In ResultFolder.Folders
WalkResult = GetNextLevel(ResultFolder.FolderPath)


For Each item In Folder.Items.Restrict("[unread] = true")
item.UnRead = False
Next
Next
Set ResultFolder = Nothing
Set Folder = Nothing
Set item = Nothing
End Sub


Function GetNextLevel(strFolderPath As String) As Long


Dim WalkResultFolder As Folder
Dim Folder As Folder
Dim item As MailItem
Dim WalkResult As Long
Set WalkResultFolder = GetFolder(strFolderPath)
For Each Folder In WalkResultFolder.Folders


WalkResult = GetNextLevel(Folder.FolderPath)


For Each item In Folder.Items.Restrict("[unread] = true")
item.UnRead = False
Next
Next
Set ResultFolder = Nothing
Set Folder = Nothing
Set item = Nothing
End Function


Function GetFolder(strFolderPath As String) As MAPIFolder


Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim i As Long
On Error Resume Next


strFolderPath = Replace(strFolderPath, "\\", "")


strFolderPath = Replace(strFolderPath, "/", "\")


arrFolders() = Split(strFolderPath, "\")


Set objFolder = Application.GetNamespace("MAPI").Folders.item(arrFolders(0))
If Not objFolder Is Nothing Then
For i = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.item(arrFolders(i))


If objFolder Is Nothing Then
Exit For
End If
Next
End If
Set GetFolder = objFolder
Set colFolders = Nothing
End Function


However, this does not mark the items in my RSS feeds folder as read.

I tried adding another section using Set BaseFolder = objnSpace.GetDefaultFolder(olFolderRssFeeds), but this didn't work.

It errored on this line saying type mismatch:

Code:
For Each item In Folder.Items.Restrict("[unread] = true")

Do I need to use something other than "Items" to reference objects in the RSS folder?

In any case, if anyone knows how to include the RSS items in the above macro, I'd appreciate it.

Thanks for any help.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,225,759
Messages
6,186,861
Members
453,380
Latest member
ShaeJ73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top