Preceptor has asked for the wisdom of the Perl Monks concerning the following question:

I've been meddling a bit with Win32::OLE and specifically trying to 'drive' outlook with it.

I've a notion of extracting emails and saving them to an archive based on various contenty-things.

So what I've got so far is:

#!/usr/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook'; use Data::Dumper; my $outlook = Win32::OLE->new('Outlook.Application') or die $!; my $namespace = $outlook->GetNameSpace('MAPI'); my $folder = $namespace->GetDefaultFolder(6)->Folders('Archive'); my $items = $folder->Items; foreach my $msg ( $items->in ) { foreach my $key ( keys %{$msg} ) { print "$key: ", $msg->{$key}, "\n"; } print Dumper \$msg; print "\n\n-----\n\n"; }

This seems to work fairly well - I can extract a 'RecievedTime' field on my messages and break it apart.

However, for a bunch of my mails, I'm getting practically every field is 'undef'.

if ( defined $msg -> {$key} ) { print "$key: ", $msg -> $key, "\n"; }
I get:
Class: 43 MessageClass: IPM.Note Subject: some_subject_line_here Sent: 1 DownloadState: 1 MarkForDownload: 1

And nothing else. I am assuming this is something that hasn't been downloaded by my mail client for some reason. I'm trying to figure out what I need to do to trigger loading of the message, in order to extract the fields I'm interested in.

Replies are listed 'Best First'.
Re: Win32::OLE and Outlook objects
by Anonymous Monk on Dec 08, 2014 at 18:54 UTC

    am assuming this is something that hasn't been downloaded by my mail client for some reason. I'm trying to figure out what I need to do to trigger loading of the message, in order to extract the fields I'm interested in.

    So what documentation are you reading?

    Download IMAP email