0

I'm having a problem with Microsoft Outlook for Mac changing UIDs of events that I create through AppleScript. I am creating an event in outlook and noting it's UID so that I can later revisit it and update it. However the issue I'm having is that when I search for the calendar entry to update it appears the UID has been changed. Applescript to create an event:

on run argv

tell application "Microsoft Outlook"

    set the_calendar to item 1 of argv
    set the_name to item 2 of argv
    set the_content to item 3 of argv
    set theTimeZone to item 8 of argv

    set start_datetime to current date -- setting this as a placeholder so we get the type as date
    set end_datetime to current date -- setting this as a placeholder so we get the type as date
    
    tell start_datetime to set {its year, its month, its day} to words of item 4 of argv
    tell start_datetime to set {its hours, its minutes, its seconds} to words of item 5 of argv

    tell end_datetime to set {its year, its month, its day} to words of item 6 of argv
    tell end_datetime to set {its hours, its minutes, its seconds} to words of item 7 of argv        

    set newEvent to make new calendar event with properties {subject:the_name, content:the_content, start time:start_datetime, end time:end_datetime, timezone:{name:theTimeZone}}
    
    --return id of newEvent
    return {id, icalendar data} of newEvent

end tell

end run

As an example for that being called with params:

116 another new one  2022-09-26 09:00:00 2022-09-26 09:15:00 Europe/London

My script then returns the following ical information:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook for Mac MIMEDIR//EN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Dublin, Edinburgh, Lisbon, London
X-ENTOURAGE-CFTIMEZONE:Europe/London
X-ENTOURAGE-TZID:8
BEGIN:STANDARD
RRULE:FREQ=YEARLY;INTERVAL=1;BYSECOND=0;BYMINUTE=0;BYHOUR=2;BYDAY=-1SU;BYM
 ONTH=10
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
DTSTART:16011001T020000
END:STANDARD
BEGIN:DAYLIGHT
RRULE:FREQ=YEARLY;INTERVAL=1;BYSECOND=0;BYMINUTE=0;BYHOUR=1;BYDAY=-1SU;BYM
 ONTH=3
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
DTSTART:16010301T010000
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:32C77928-016E-42D3-9703-8397F5D43257
X-ENTOURAGE_UUID:32C77928-016E-42D3-9703-8397F5D43257
DTSTAMP:20220919T055852Z
DTSTART;TZID="Dublin, Edinburgh, Lisbon, London":20220926T090000
DTEND;TZID="Dublin, Edinburgh, Lisbon, London":20220926T091500
LAST-MODIFIED:20220919T055852Z
SUMMARY:another new one
ORGANIZER:MAILTO:123@gmail.com
SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-CDO-INSTTYPE:0
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT00H15M00S
END:VALARM
END:VEVENT
END:VCALENDAR

Notice: UID:32C77928-016E-42D3-9703-8397F5D43257.

When I then search for that calendar entry using the following code I see that the UID has been changed.

Search code:

tell application "Microsoft Outlook"
    set theCal to calendar id 116
    set theTitle to "another new one"
    
    set existingEvents to get (calendar events of theCal whose its subject is theTitle)
    
    repeat with eachEvent in existingEvents
        the subject of eachEvent
        
    end repeat
    
end tell

This will then display:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook for Mac MIMEDIR//EN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Dublin, Edinburgh, Lisbon, London
X-ENTOURAGE-CFTIMEZONE:Europe/London
X-ENTOURAGE-TZID:8
BEGIN:STANDARD
RRULE:FREQ=YEARLY;INTERVAL=1;BYSECOND=0;BYMINUTE=0;BYHOUR=2;BYDAY=-1SU;BYM
 ONTH=10
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
DTSTART:16011001T020000
END:STANDARD
BEGIN:DAYLIGHT
RRULE:FREQ=YEARLY;INTERVAL=1;BYSECOND=0;BYMINUTE=0;BYHOUR=1;BYDAY=-1SU;BYM
 ONTH=3
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
DTSTART:16010301T010000
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:040000008200E00074C5B7101A82E00800000000F1FB53E5ECCBD80100000000000000
 0010000000732F1FFEB492A14C86170F6940FD7E4D
X-ENTOURAGE_UUID:32C77928-016E-42D3-9703-8397F5D43257
X-MICROSOFT-EXCHANGE-ID:AQMkAGM4YzkwMAItNDkwNi0xYTYwLTAwAi0wMAoARgAAA4dYA3
 WZ7wtPubkA4F2cDA3rBwAQdl8jZ5nbQI1VWqJLfBXKAAACAQ0AAAAQdl8jZ5nbQI1VWqJLfBXK
 AAAAp9VvwQAAAA==
X-MICROSOFT-EXCHANGE-CHANGEKEY:EHZfI2eZ20CNVVqiS3wVygAAp7OZgw==
DTSTAMP:20220919T085323Z
DTSTART;TZID=\"Dublin, Edinburgh, Lisbon, London\":20220926T090000
DTEND;TZID=\"Dublin, Edinburgh, Lisbon, London\":20220926T091500
LAST-MODIFIED:20220919T085323Z
SUMMARY:another new one
ORGANIZER:MAILTO:123@gmail.com
SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-CDO-INSTTYPE:0
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT00H15M00S
END:VALARM
END:VEVENT
END:VCALENDAR

Notice here UID is now UID:040000008200E00074C5B7101A82E00800000000F1FB53E5ECCBD80100000000000000 0010000000732F1FFEB492A14C86170F6940FD7E4D.

However the X-ENTOURAGE_UUID is still the same: X-ENTOURAGE_UUID:32C77928-016E-42D3-9703-8397F5D43257

Does anyone know what causes this and how to stop it happening?

I guess my options here are:

  1. Figure out what is causing this and fix it
  2. Switch over to using X-ENTOURAGE_UUID to identify calendar items requiring changes. I'm not sure what the advantages or disadvantages of this would be
  3. Adjust approach so that I generate the ics files myself, including generating my own UID, and then importing those to outlook rather than telling outlook to create the calendar entries for me.

Additional info about the calendar, if useful:

  • It is a gmail calendar that I manage through outlook
peetysmith
  • 157
  • 1
  • 10
  • You haven't been clear what actually gets returned by `id of newEvent` and whether this changes along with the UID or not. The important thing is whether, given some `id of newEvent` (which I'll refer to as the value _`k`_) at the time of its creation, are you later able to retrieve the same event with the AppleScript statement `get calendar event id k` ? – CJK Sep 22 '22 at 20:56
  • id of newEvent remains the same. It can be used to retrieve the same event in the same way that I searched for it with title in the example I gave above. I considered using this as my index but the challenge is that the program may need to run on more than one machine, and therefore IDs would be different, and I don't know when these IDs would get reset, e.g. if a user upgrades outlook or reinstalls, so I cannot rely on it. – peetysmith Sep 23 '22 at 04:45
  • You could add the Gmail account to Apple Mail just in order to compare the data pertaining to the same emails that gets returned by each mail client. Also investigate whether the `id` property (which needs tweaking in Mail in order to have it return correctly) is app-specific (probably) or derived from intrinsic message data (possibly). – CJK Sep 25 '22 at 21:54

0 Answers0