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

I have started working with Win32::OLE, and it has been fun. But now I need Perl to access public calendars, and I've run into problems. I can make Perl access my default calendar, but not the public calendars. We are using an Exchange server. This question seems to pop up every now and then, but I haven't seen any solutions. There are some great Perl & Outlook scripts here, but none (that I've seen) address Outlook public calendars. One monk posted a Calendar parsing program wherein he wrote:
#open the default Calendar and grab the items in the calendar (twice.. +.) my $namespace = $outlook->GetNameSpace("MAPI") or die "can't open MAPI + namespace\n"; my $recurringitems = $namespace->GetDefaultFolder(olFolderCalendar)->{ +Items}; my $calitems = $namespace->GetDefaultFolder(olFolderCalendar)->{Items} +;
My first idea was to change GetDefaultFolder to GetPublicFolder. Then I provided the address of the public folder as a string (I was guessing here), so we end up with:
my $recurringitems = $namespace->GetPublicFolder("\\Path\to folder")->{Items}; my $calitems = $namespace->GetPublicFolder("\\Path\to\folder")->{Items +};
But this didn't work at all. I have full permissions for these public folders. I looked at Microsoft's documentation and came away with the feeling that I am going in the wrong direction. Any ideas would be appreciated.

Replies are listed 'Best First'.
Re: Outlook public folders
by Anonymous Monk on Mar 14, 2002 at 08:28 UTC
    That's no so impossible as it seems to be :-) For example if I want to see calendar of Mr. Jan Mlcak I'll do it in the following way:
    my $namespace = $outlook->GetNameSpace("MAPI") or die "can't open MAPI namespace\n";
    
    my $myRecipient = $namespace->CreateRecipient("Jan Mlcak");
    $myRecipient->Resolve;
    
    my $recurringitems;
    my $calitems;
    
    if( $myRecipient->{Resolved} ) {
    
      $recurringitems = $namespace->GetSharedDefaultFolder($myRecipient, olFolderCalendar)->{Items};
      $calitems =       $namespace->GetSharedDefaultFolder($myRecipient, olFolderCalendar)->{Items};
    } else {
      die "Bad times.";
    }
    
    
    
Re: Outlook public folders
by Jules_Verne (Novice) on Mar 14, 2002 at 15:31 UTC
    Thanks AM. I really need to learn more about Win32::OLE. This page provided me with what I was looking for:

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q208520

    What I needed to use was the folders object. Here's the description:

    Folders Object

    You can use the Folders object to refer to any folder that is visible in the Outlook folder list. This object is typically used to refer to an Exchange public folder or any other folder that is not a default Outlook folder.

    Note that you typically start at the top-most folder and work your way down to the folder you need to reference. Also note that the folder names are case-sensitive and must exactly match the names as they appear in the Outlook folder list.

    And here's what my code looks like:

    my $namespace = $outlook->GetNameSpace("MAPI") or die "can't open MAPI + namespace\n"; my $myFolder1 = $namespace->Folders("Public Folders"); my $myFolder2 = $myFolder1->Folders("All Public Folders"); my $myFolder3 = $myFolder2->Folders("MITSL"); my $myFolder4 = $myFolder3->Folders("Conference Facility Schedules"); my $myFolder5 = $myFolder4->Folders("R523 - Conf Room M"); my $recurringitems = $myFolder5->{Items}; my $calitems = $myFolder5->{Items};
A reply falls below the community's threshold of quality. You may see it by logging in.