Here's a simple solution. It works for me, but you might have environmental factors (i.e. security) which might necessitate some tweaking.
use Win32::OLE;
use Win32::OLE::Const ('Microsoft Outlook');
my $ol = new Win32::OLE 'Outlook.Application';
my $sess = $ol->GetNamespace('MAPI') or die ;
for my $folder ( $sess->GetDefaultFolder( olFolderInbox ) )
{
print qq(\nUnRead items in folder "), $folder->FolderPath, qq(":\n
+\n);
my $items = $folder->Items;
local( $\, $, ) = ( "\n", "\t" );
print $_->ReceivedTime->Date, $_->Subject
for grep $_->UnRead, in $items;
}
It prints the received time and the subject line of each UnRead item.
It does not attempt to sort the items; it prints them in the order
returned by the MAPI interface.
NB:
The UnRead method seems to have a bug. It returns false for some items
which appear as unread in my Outlook inbox. I suspect that these items were
read and subsequently manually changed back to "unread"; and that this method
is somehow able to detect this. It may be looking at the definedness of a
"read on date" attribute, rather than the user-visible/settable status.
A word spoken in Mind will reach its own level, in the objective world, by its own weight
|