At Microsoft we get a fair bit of mail with all the distribution lists. The 'Mark All as Read' command only operates on the current folder so I knocked together a macro to do the recursion. The code below iterates the selected folder and it's children marking all the mails as 'read'. There may be optimisations as my VBA is a bit rusty so I'd love to hear what they are.
Sub RecursiveMarkAsRead() MarkFolderAsRead Application.Explorers.Item(1).CurrentFolder, TrueEnd SubSub MarkFolderAsRead(ByVal parent As MAPIFolder, ByVal recurse As Boolean) On Error GoTo ErrorHandler If parent.UnReadItemCount > 0 Then Dim item As Object For Each item In parent.Items If TypeName(item) = "MailItem" Then Dim mail As MailItem Set mail = item mail.UnRead = False End If Next End If If recurse = True Then Dim folder As MAPIFolder For Each folder In parent.Folders MarkFolderAsRead folder, recurse Next End IfExit SubErrorHandler:' Ignore this folderEnd Sub
Page rendered at Saturday, February 11, 2012 3:46:04 PM (GMT Standard Time, UTC+00:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.