Sick of getting annoying emails and forwards? I am!
Where I work we get hundreds of emails like this; All coming from the same sender with the same subject line. I wrote this script to take care of this problem.
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';
my $MailBox = 'Mailbox - WebOps';
my $count = 0;
$|++;
$Win32::OLE::Warn = 3;
my $Outlook = Win32::OLE->GetActiveObject('Outlook.Application') or Wi
+n32::OLE->new('Outlook.Application', 'Quit');
my $ol = Win32::OLE::Const->Load($Outlook);
my $Inbox = $Outlook->GetNameSpace("MAPI")->Folders("$MailBox")->Folde
+rs("Inbox") or die "Can't open MAPI namespace: $!";
my $personal = $Inbox->Folders("silent11's To-Do")->Folders("junk") or
+ die "Can't open MAPI namespace: $!";
foreach my $item (in $Inbox->{Items}){ # {Subject},{SenderName},{Bod
+y}, etc...;
if ($item->{Subject} eq 'SERVER ERROR: /cgi-bin/who_cares.pl - aut
+oforwarded'){
$item->Move($personal) && $count++;
}
}
print "\n$count items moved\n";
-silent11