Submitted By: Kent Finkle

List the dates email messages in the Outlook Inbox were sent, and how many messages were sent on each of those dates.

PowerShell
Edit|Remove
$comments = @'
Script name: Tally-Messages.ps1 
Created on: Thursday, August 09, 2007 
Author: Kent Finkle 
Purpose: How can I use Windows Powershell to 
Tally Mail Messages Using Microsoft Outlook? 
'@ 
$hash = @{} 
$olFolderInbox = 6 
$o = new-object -comobject outlook.application 
$n = $o.GetNamespace("MAPI") 
$f = $n.GetDefaultFolder($olFolderInbox) 
$Items = $f.Items 
foreach ($Item in $Items) { 
    If ($Item.SentOn -ne $null) { 
        $dt = ($Item.SentOn).toshortdatestring() 
        If ($hash[$dt] -eq $null) { 
            $hash[$dt] = 1 
            Write-Host($dt) 
        } 
        Else { 
            $hash[$dt] += 1 
        } 
    } 
} 
foreach ($dt in $hash.Keys) { 
    Write-Host $dt, $hash[$dt] 
}