If Outlook is available you may be better off using that.

This is a skeleton of something I've used. You'd need to adjust the mailbox name.

#!/usr/bin/perl use v5.12.2; use warnings; use strict; use Win32::OLE; my $mail = parse_inbox(); sub parse_inbox{ # use existing instance if Outlook is already running, or launce a n +ew 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, 'Mailbox - John Sharpe' ); # adjust to suit my $folder = seekFolder( $mailbox, 'Inbox' ); my (%table); for (my $i = 1; $i <= $folder->Items->Count; $i++) { my $sender_name = $folder->Items->Item($i)->SenderName; my $subject = $folder->Items->Item($i)->Subject; my $body = $folder->Items->Item($i)->Body; say $subject; # process # store something in table } return \%table; } 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); } } return; }
Tested with Outlook 2003. There is a snag in that after the script is started Outlook complains that something is trying to look at the contact list. You need to click a checkbox and OK.

In reply to Re: Extracting email messages and attachments from a microsoft outlook .pst file by wfsp
in thread Extracting email messages and attachments from a microsoft outlook .pst file by pankaj_it09

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.