use Win32::OLE; #use Win32::GuiTest; use Win32::Clipboard; $OL = Win32::OLE->GetActiveObject('Outlook.Application'); $NameSpace = $OL->GetNameSpace("MAPI"); $Inbox = $NameSpace->GetDefaultFolder(6); #-- inbox folder $Deleted = $NameSpace->GetDefaultFolder(3); #-- deleted items folder $Root = $Inbox->Parent(); $MyAccount = $Root->Folders("Inbox"); $MyAccountOK = $MyAccount->Folders("Filtered"); $Clip = Win32::Clipboard(); #$Clip->Empty(); $cnt=$MyAccount->Items->Count; print "count = $cnt"; while ($cnt > 0) { $Clip->Empty(); #-- empty the clipboard #$MyAccount->Items($cnt)->Display; #-- display/open message with index of $cnt in the MyAccount folder undef $text; $text=$Clip->Get(); #-- get clipboard contents #print "text = $text\n"; $text=~tr/A-Za-z.@/*/c; #-- convert all but listed valid characters to * $text=~tr/*//d; #-- now delete asterisks $text=lc($text); #-- convert to lowercase # -- now check for our email address in the internet header text if ($text !~ /myaccount\@yahoo\.com/) { print "No\t"; #-- move message to Deleted Items folder } else { print "Yes\n"; $MyAccount->Items($cnt)->Move($MyAccountOK); #-- move message to MyAccount->Filtered folder } $cnt--; }