I was hoping to get a powershell script that would do the following
1) Connect to outlook 2007
2) Go to Mailbox folder (not an inbox subfolder) called 'Processes'
3) Delete all email from that folder older than 3 days old
I did some searching, I have found very useful things like how to empty a deleted items folder. I can even display all messages in that folder using this script snippet. But whenever I try to filter it down to email older than 3 days old, it blows up on me. I was attempting to use a | Where-Object pipe to reduce it and there are thousands of messages in that folder.
$outlook = New-Object -ComObject Outlook.Application
$olFolderInbox=6
$n = $outlook.GetNamespace("MAPI")
$f = $n.GetDefaultFolder($olFolderInbox)
$mailbox = $n.Folders.Item($f.Parent.Name)
$folder = $Mailbox.Folders.Item("Processes")
$folder.Items
#Clean out any open connections
$outlook = $n = $f = $mailbox = $folder = $null;