#!/usr/bin/perl -w use strict; use Win32::OLE; $| = 1; # use existing instance if Outlook is already running, or launce a new one my $ol; eval {$ol = Win32::OLE->GetActiveObject('Outlook.Application')}; die "Outlook not installed" if $@; unless (defined $ol) { $ol = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Outlook"; } my $mailbox = seekFolder($ol->Session, 'foo@bar.com'); my $folder = seekFolder($mailbox, 'Inbox'); my @fields = qw(SenderName SenderEmailAddress ReplyRecipientNames SenderEmailType SentOn ReceivedTime MessageClass Size Subject To CC BCC Unread InternetCodepage Importance EntryID ConversationIndex ConversationTopic Class BodyFormat ); my $end = $folder->Items->Count; for (my $i = $end; $i > $end-5; $i--) { print "======================================================================\n"; foreach my $k (@fields) { print "$k: ".$folder->Items->Item($i)->{$k} . "\n"; } } Win32::OLE->FreeUnusedLibraries(); sub seekFolder { my $obj = shift; my $target = shift; for (my $i = 1; $i <= $obj->Folders->Count; $i++) { if ( $obj->Folders->Item($i)->Name eq $target ) { return $obj->Folders->Item($i); } } }