#########################################################################################
#- -- This program inspects the
internet header of all Microsoft Outlook (2002 SP-2) messages in the
user-defined “MyAccount”
#-- directory to determine if
the email was sent to myaccount@charter.net If
this is not the case, then it is spam and
#-- the program puts the email
in the “Deleted Items” folder. If the email was sent to myaccount@charter.net
place
#-- the email in the
MyAccount->Filtered folder. This program assumes Microsoft Outlook is
running. This program
#-- does not cause the Outlook
Security Window to open, so nothing to worry about.
#-- Author – Eric C. Hansen, May
2004 eric.amerwood@charter.net
####################################################################################################
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("MyAccount");
$MyAccountOK
= $MyAccount->Folders("Filtered");
$Clip
=
Win32::Clipboard();
@wins =
Win32::GuiTest::FindWindowLike(0,"^Microsoft Outlook",'mspim_wnd32');
#-- mspim_wnd32 is the
class
Win32::GuiTest::SetForegroundWindow($wins[0]);
$cnt=$MyAccount->Items->Count; #-- get a count of
messages in folder "MyAccount"
while ($cnt > 0)
{
$Clip->Empty(); #-- empty the
clipboard
$MyAccount->Items($cnt)->Display; #--
display/open message with index of $cnt in the MyAccount
folder
Win32::GuiTest::SendKeys("%Vp");
#--
open options dialog ALT-V-p
Win32::GuiTest::SendKeys("{TAB
6}");
#--
move down to internet header field
Win32::GuiTest::SendKeys("{APP} {DOWN 2} {ENTER}");
#-- put internet header in clipboard
Win32::GuiTest::SendKeys("{TAB}");
#--
move to Cancel Button
Win32::GuiTest::SendKeys("{ENTER}");
#--
press Cancel Button
Win32::GuiTest::SendKeys("%{F4}");
#--
close message ALT-F4
undef $text;
$text=$Clip->Get();
#-- get clipboard contents
$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\@charter\.net/) {
$MyAccount->Items($cnt)->Move($Deleted);
#--
move message to “Deleted Items” folder
} else {
$MyAccount->Items($cnt)->Move($MyAccountOK); #-- move
message to “MyAccount->Filtered folder
}
$cnt--;
}
#-- end
script