Submitted By: Kent Finkle

Randomly select an email message from an Outlook mail folder.

PowerShell
Edit|Remove
$comments = @'
Script name: Random-Email.ps1 
Created on: Monday, August 13, 2007 
Author: Kent Finkle 
Purpose: How can I use Windows Powershell to 
Randomly Select an Email From an Outlook Mail Folder? 
'@ 
 
$olFolderInbox = 6 
 
$o = new-object -comobject outlook.application 
$n = $o.GetNamespace("MAPI") 

$f = $n.GetDefaultFolder($olFolderInbox) 
 
$a = new-object random 

$b = $a.next(1,$f.items.Count) 
 
Write-Host($f.items.item($b).SenderName)