in reply to Extracting email messages and attachments from a microsoft outlook .pst file
This is a skeleton of something I've used. You'd need to adjust the mailbox name.
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.#!/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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extracting email messages and attachments from a microsoft outlook .pst file
by pankaj_it09 (Scribe) on Apr 29, 2011 at 13:02 UTC | |
|
Re^2: Extracting email messages and attachments from a microsoft outlook .pst file
by pankaj_it09 (Scribe) on Apr 20, 2011 at 12:24 UTC | |
by wfsp (Abbot) on Apr 20, 2011 at 12:39 UTC | |
by pankaj_it09 (Scribe) on Apr 20, 2011 at 12:54 UTC |