I am having some troubles with the Outlook OLE and accessing some of its methods from Perl. Specifically, I'm looking to get the attachments from a file sitting in a public mailbox and move them to the network. A paired down version of my code is below:

use strict; use warnings; use Win32::OLE; use Win32::OLE::Const '.*Outlook'; my $outlook = Win32::OLE->GetActiveObject('Outlook.Application'); die "Outlook isn't running." unless $outlook; my $namespace = $outlook->GetNameSpace("MAPI"); # some code here to get the location of the mailbox and the inbox of t +hat mailbox my $inbox = $namespace->Folders($i)->Folders($j); # some code here to get to the proper email message my $text = $inbox->Items->Item($wanted);

Now from here I know I have the right message because print $text->Subject; will return the subject line. The problem is I can't seem to get anything else. I've looked through the object browser in outlook and I've tried Attachments but it doesn't seem to work. For instance, print $text->Attachments->Count; just returns the warning "Can't call method "Count" on an undefined value." Also, body/to/from etc. don't seem to return anything either. Does anyone have any tips/ideas? I checked the class of the item and it is class 43 (mailitem.)


In reply to Accessing Outlook OLE with Perl by Anonymous Monk

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.