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

Working on a small project to read a personal outlook calendar looking for corrupt data. I believe I have corrupt data in an recurring calendar event. The Following code started from: http://www.perlmonks.org/?node_id=660500 And am looking to add reference to recurring items from this http://www.microsoft.com/technet/scriptcenter/resources/officetips/sept05/tips0901.mspx The issue I'm having is I don't understand how to access the data structure RecurrancePattern and its objects. Here is the semi working code - Pulls calendar data and only displays if its a recurring calendar item.
use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook'; my $outlook = Win32::OLE->new('Outlook.Application') or die "Error!\n"; my $counter; my $namespace = $outlook->GetNamespace("MAPI"); my $cal = $namespace->GetDefaultFolder(olFolderCalendar); my $items = $cal->Items; #$appts->{IncludeRecurrences} = 'True'; #$items->Filter{IsRecurring} = 'True'; for my $itemIndex (1..$items->Count) { my $appts = $items->item($itemIndex);# or die("error getting cal appts +: " . Win32::OLE->LastError()); #print Win32::OLE->LastError(); #next if not defined $appts; if ($appts->{IsRecurring} >= 1 ) { my $pattern = $apps->{RecurrencePattern}; $counter++; print "\n\n"; print "subject = " . $appts->{Subject}."\n"; print "Start = " . $appts->{Start}->Date."\n"; print "Organizer = " . $appts->{Organizer}."\n"; print "Start Time = " . $appts->{Start}->Time."\n"; print "End = " . $appts->{End}->Date."\n"; print "End time = " . $appts->{End}->Date."\n"; print "Duration = " . $appts->{Duration}."\n" ; #1 minute print "Location = " . $appts->{Location} ."\n"; print "body = " . $appts->{Body} ."\n"; print "ReminderMinutesBeforeStart = " . $appts->{ReminderMinutesBefore +Start} ."\n"; print "BusyStatus = " . $appts->{BusyStatus} ."\n"; print "AllDaEvent = " . $appts->{AllDayEvent} ."\n"; print "EntryID = " . $appts->{EntryID} ."\n"; print "CreationTime = " . $appts->{CreationTime}->Date, " ",$appts->{C +reationTime}->Time."\n"; print "IsRecurring = " . $appts->{IsRecurring} ."\n"; print "Pattern Start = " . $appts->{RecurringPattern}->{StartDate}."\n +"; print "Pattern End = " . $appts->{RecurringPattern}->{EndDate}."\n"; } } print $counter . "Total Recurring items\n";

Replies are listed 'Best First'.
Re: Reading Outlook recurring events
by NetWallah (Canon) on Jan 07, 2008 at 23:23 UTC
    It looks like you are populating "$pattern" in a manner I cannot find documented.

    Your MS Technet reference seems to be fairly straightforward to translate to perl.

    More details on the pattern object is available in the documentation for the GetRecurrencePattern method

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

Re: Reading Outlook recurring events
by roboticus (Chancellor) on Jan 08, 2008 at 00:29 UTC
    Perhaps you should put in the "t", so the line looks like:
    my $pattern = $appts->{RecurrencePattern}; # ^ add this "t"!
    Had you bothered to put in use strict & company, perl would've given you a diagnostic to clue you in to the problem....

    ...roboticus