#!perl # Author: Robbie Allen (rallen@rallenhome.com) # Oct 2003 # # This script generates a small dialog box # that displays the UNREAD messages in your # inbox. I use Outlook Redemption (http://www.dimastr.com/redemption/) # to work around the problem that with Outlook's # new security feature it prompts the user to allow # an external program to access messages. Redemption # bypasses this. use Win32::OLE 'in'; use Win32::GUI; my $I = Win32::GUI::Icon->new("mail.ico",0); my $F = new Win32::GUI::Font( -name => "Arial", -size => 14, -bold => 0, ); my $WC = new Win32::GUI::Class( -name => "Outlook_GUI", -icon => $I, ); my $MW = Win32::GUI::Window->new( -title => ' Outlook Inbox Checker', -left => 763, -top => 615, -width => 260, -height => 100, -name => 'MainWindow', -class => $WC, -topmost => 1, -font => $F, -icon=> $I, ); $MW->AddLabel( -align => "left", -name => "OutlookData", -text => OutlookData(), -left => 5, -top => 5, -width => 260, -height => 100, -wrap => 0, -color => 1, ); my $Timer1 = $MW->AddTimer("Timer1", 15000); $MW->Show(); Win32::GUI::Dialog(0); sub MainWindow_Terminate { $MW->PostQuitMessage(1); } sub Timer1_Timer { $MW->OutlookData->Text(OutlookData()); } sub OutlookData { my $objApp = Win32::OLE->GetActiveObject("Outlook.Application"); return "Outlook not open" unless ref $objApp; my $objOutlook = $objApp->GetNameSpace("MAPI"); my $objMAPIFolder = $objOutlook->GetDefaultFolder(6); my $s = $objOutlook->GetDefaultFolder(6)->UnreadItemCount . " unread; "; return "Outlook not open" unless ref $objOutlook->GetDefaultFolder(6)->Items; $s .= $objOutlook->GetDefaultFolder(6)->Items->Count . " total\n"; if ($objOutlook->GetDefaultFolder(6)->UnreadItemCount > 0) { foreach my $aItem (in $objOutlook->GetDefaultFolder(6)->Items) { if ($aItem->Unread) { my $sItem = Win32::OLE->CreateObject("Redemption.SafeMailItem"); $sItem->{Item} = $aItem; $s .= $sItem->SenderName . " -- " . $sItem->Subject . "\n"; } } } return $s; }