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.


In reply to Win32::OLE and Outlook objects by Preceptor

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.