Applescript and Outlook - can't get all occurrences of repeating event

Hi all,

I’m trying to export a list of all the events in my Outlook Calendar into a text file using the following code:

set eventDetails to ""
set currentDate to current date
set yearFromNow to currentDate + (365 * days)

tell application "Microsoft Outlook"
    set theCalendars to calendars
    repeat with currentCalendar in theCalendars
        repeat with currentEvent in calendar events of currentCalendar
            if start time of currentEvent > date "Wednesday, 1 January 2014 00:00:00" and start time of currentEvent < yearFromNow then

                set eventDetails to eventDetails ¬
                    & (subject of currentEvent) ¬
                    & "\t" & (start time of currentEvent) ¬
                    & "\t" & (end time of currentEvent) ¬
                    & "\t" & (is occurrence of currentEvent) ¬
                    & "\t" & (all day flag of currentEvent) ¬
                    & "\t" & (has reminder of currentEvent) ¬
                    & "\t" & (reminder time of currentEvent) ¬
                    & "\n"

            end if
        end repeat
    end repeat

    display dialog (eventDetails)
end tell

This works for most of my events, but some occurrences of my recurring events do not get written out. For example, for one weekly recurring event it writes out 7 of the 10 occurrences between May and June, but then none of the occurrences after June (until December when the recurring event ends).

Anyone any idea why?

Thanks in advance

Did you ever find out the answer to this? I’m having the same issue.

Below code will return most things but seems to inconsistently miss recurring events.

set entries to every calendar event of theCal whose start time is greater than or equal to startDate and end time is less than or equal to endDate

Just in case anyone else is trying to do this, the reason is the way that Outlook (and some other calendars) handle recurring items is that they create a single calendar event that has details about how the recurrence should happen.

This means that if a recurring event was created 3 weeks ago to happen every week for the next year and you looked for events with start date this week you would not find it, despite there being an actual recurrence due to happen this week.

Outlook, etc, must calculate out the calendar when they draw the calendar view for you. Not exactly sure what they do to keep this performant, especially when trying to look at free/busy information for multiple people, but this seems to be how they do it.

I can only imagine the reason you saw some instances of a recurring event was because they were edited and therefore behave slightly differently. Whenever I run similar code to get all calendar events within a period I only get the original occurrence or standalone events that fall within the time window I’m searching.

Logic tells me that every time Microsoft Outlook (and Calendar.app) is launched, it calculates (and stores in RAM) a finite number of repeated events for the future, not an infinite number. Otherwise, RAM overflow would occur.

In order to calculate repeatable events for the year ahead, you will most likely have to do it with the usual mathematical operations. Himself.