Mark All Email in Mailbox As Read

I have an Outlook mailbox as follows:





Using PowerShell, how do I recurse through each folder (and its subfolders) and mark every message as read? (5_Misc is actually my "inbox"; I renamed it using MFCMAPI).

 

I've tried several scripts, but each one errors.  I can post them if it helps, but if there's a standard way to do it that'd be great.


Thanks for any help.

Parents
  •  

    Hopefully this will get around your funky inbox name.

    function Get-SubFolder($mailboxFolder){
        foreach ($mail in $mailboxFolder.Items){
            $mail.UnRead = $false
        }
        #Recurse sub folders
        foreach ($folder in $mailboxFolder.folders){
            Get-SubFolder $folder
        }
    }

    $outlook = New-Object -ComObject outlook.application
    $namespace = $outlook.GetNamespace("MAPI")
    $mailbox = $namespace.stores | Where-Object {$_.ExchangeStoreType -eq 0}
    $mailbox.GetRootFolder().folders | ForEach-Object { Get-SubFolder $_}

Reply Children
No Data