Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell and Outlook 2007, trying to delete messages in a folder older than date

$
0
0

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;


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>