0
votes

I have a script that creates an Outlook calendar event from content in an email (also from Outlook). The email contains the name of the event, date/time, and a single attendee's information. The event is first created with the one attendee that was specified from the email.

I will receive more emails that indicate additional attendees (one per email) and which event the new attendee should be added to.

Right now my script is able to create a calendar event(with location, subject, start/end time, content, and reminder time) and add one required attendee to the event, then send the event to the attendee.

I need to get access to existing events with the same subject and add more attendees to the event.

Right now I'm trying to achieve this with this code:

tell application "Microsoft Outlook"

    <...>

    set textContent to paragraphs of msgContent

    --Check for existing calendar event
        set prevEvent to "false"
        try
            set existingEvent to get (calendar event of calendar whose its subject is item 9 of textContent) 
            tell existingEvent
                make new required attendee at end of attendees with properties {email address:{name:attendeeName, address:attendeeEmail}}
            end tell
            open existingEvent --This is done so I can make sure it has the info I need. The I'm done it will be changed to "send meeting..."
            set prevEvent to "true"
        on error
            log "Event does not exsist"
        end try

    if prevEvent = "true" then exit repeat

    <...>

    --Code to create a new event
    set msgToSend to make new calendar event with properties {location:msgLocation, subject:msgSubject, start time:meetingDateTime, end time:endTime, content:msgNewContent, has reminder:true, reminder time:30}
    <...>

end tell

I'm not getting an error but my code just exits the try/error so I think my "set existingEvent to" is wrong.

1
To trace current error, remove the 'try/on error/end try' block and replace by 'if' to test if the event has been found. It will give you exactly where error is. Usually, you should 'get every calendar event whose...' which gives you a list of event...hopefully a list with only 1 member. - pbell

1 Answers

0
votes

I was able to add an attendee with this code

    --Create/add attendee for calendar message invite
make new required attendee at msgToSend with properties {email address:{name:"First Last", address:"[email protected]"}}

Where msgToSend is a new calendar event that will be sent out. This event is created by

    --Create calendar message invite
    set msgToSend to make new calendar event with properties {location:msgLocation, subject:msgSubject, start time:meetingDateTime, end time:endTime, content:msgNewContent, has reminder:true, reminder time:30}

I was not able to determine how to check for and modify existing events using AppleScript. I switched to using Microsoft Flow to achieve my task.