I don't think Microsoft will ever give out the exact format that their
database is in for parsing, for obvious reasons.  If you want to parse the
contents of mailboxes, I would recommend checking out the Win32::Exchange
module and a good long research session at www.microsoft.com/msdn.  You can
use Win32::OLE to do almost anything that a vbscript can do.  I would also
recommend trying out OutlookSpy.  I can't remember where I got it, but do a
search on Google and you should find it.  It definitely helps when it comes
to finding methods and objects that you can use if you decide to go the
Win32::OLE route.  Here's some code I started when I was looking into the
same kind of thing.

Of course, this must be done on a Win32 system.

########################################
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
use Time::Local;

print "Opening a new MAPI.Session object...\n";
my $session = Win32::OLE->new('MAPI.Session') or die "Couldn't create a new
MAPI.Session object!\n$!\n";

print "Logging on...\n"; 
$session->Logon();

print "Opening the Inbox...\n";
my $inbox = $session->Inbox || die;

print "Getting the list of folders...\n";
my @folders = ();
my $folders = $inbox->Folders || die;
my $folder = $folders->GetFirst || die;
while($folder){
        push @folders,$folder->Name;
        $folder = $folders->GetNext;
}

print "\n\n";
print "Folders\n";
print "======================\n";
foreach(sort @folders){
        print "  $_\n";
}

print "\n\n";
print "Messages\n";
print "======================\n";

print "Getting the Messages...\n";      
my $messages = $inbox->Messages || die;

print "Getting the first message...\n";
my @msgs = ();
my $message = $messages->GetFirst || die;

while($message){
        my $msgtime = $message->TimeReceived;
        my @temparray = ($message,$msgtime);
        push @msgs,[EMAIL PROTECTED];
        $message = $messages->GetNext;
}

foreach my $item(@msgs){
        my @date = split /\s+/,@{$item}[1];
        my($mon,$mday,$year) = split /\//,$date[0];
        my($hour,$min,$sec) = split /:/,$date[1];
        if($date[2] eq 'PM'){
                $hour += 12;
        }
        if($hour == 24){
                $hour = 0;
        }
        push @{$item},timelocal($sec,$min,$hour,$mday,$mon,$year);
}
my $i;  
foreach my $msg(sort{$b->[2] cmp $a->[2]} @msgs){
        if($msg->[0]->FolderID eq $inbox->ID){
                print "\n\n";
                print "Received: ".$msg->[0]->TimeReceived."\n";        
                print "Subject: ".$msg->[0]->Subject."\n";
                print "From: ".$msg->[0]->Sender->DisplayName."\n\n";
                print $msg->[0]->Text;
                print "\n";
                print
"----------=============#############==============-----------\n";
        }
        $i++;
        if($i > 10){
                exit 0;
        }
}

###############################################

-----Original Message-----
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 21, 2003 1:25 PM
To: Morrison, Trevor (Trevor)
Cc: [EMAIL PROTECTED]
Subject: Re: Exchange Server Mailbox format


"Morrison, Trevor (Trevor)" wrote:

> Hi,
>
> Does anyone know which mail box storage format an 2000 exchange server
uses.  I am looking to parse emails that are stored in the folders.

You should probably search the Microsoft knowledge base for that
information.  It is not really a Perl question.  There may be Perl modules
that can parse those mailboxes, though.

As a note:  Please do not use return receipt requests when posting to this
group.  They are annoying and intrusive.

Joseph

>
>
> Thanks
>
> Trevor


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to