in reply to MS Outlook GetSharedDefaultFolder

Okay, I misunderstood what you were trying to accomplish with the if statements initially and I apologize.

Try moving the variable declarations outside of the if statements.

#!/perl/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Variant; #Needed for ReceivedTime constant. my $Outlook = Win32::OLE->new('Outlook.Application'); my $namespace = $Outlook->GetNameSpace("MAPI"); my $recipient = $namespace->CreateRecipient("inboxname"); if ($recipient) { print "OK\n"; } else { print "$!\n"; } $recipient->Resolve; # see url if ($recipient->Resolved) { print "Resolved\n"; } else { print "$!, unable to resolve\n"; } my $p2 = $namespace->GetSharedDefaultFolder($recipient,6); # what does + this return? if ($p2) { print "OK2\n"; } else { print "$!, Code fails here, does not return an error\n"; }

(Untested)

See also GetSharedDefaultFolder

Replies are listed 'Best First'.
Re: Re: MS Outlook GetSharedDefaultFolder
by Mitch (Sexton) on Sep 03, 2003 at 22:23 UTC
    I tried that, but $p2 is empty and doesn't return an error. I am able manually open the inbox (via Outlook) so I don't think it's a permission issue. In the past I have been able to read from Public folders, but this is the first time I've tried a shared inbox. I was hoping it would turn out to be a syntax issue, but I think the syntax is OK.

    Mitch

      Perhaps you should use Win32::OLE->LastError() instead of $! for a descriptive OLE error msg.

      $! is for perl errors not OLE, note that Win32::OLE->LastError() is context sensitive like $!.

      It reports the error number in numeric context and an error msg in string context

      I would even consider setting the Warn option to always croak, in normal situations like this

      Win32::OLE->Option(Warn => 3);

      HTH

        Thanks for the tip. I used the LastError() and it returned

        OLE exception from "Microsoft Outlook": The messaging interface has returned an unknown error. If the problem persists, restart Outlook.
        Win32::OLE(0.1502) error 0x80004002: "No such interface supported"
        in METHOD/PROPERTYGET "GetSharedDefaultFolder"

        Mitch