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:
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:
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.
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.