Documentation Archive

Developer

Calendar Scripting Guide

Adding an Attendee to an Event

Calendar events can contain attendees. Listing 12-1 and Listing 12-2 demonstrate how to add an attendee to an event.

APPLESCRIPT

Open in Script Editor

Listing 12-1AppleScript: Adding an attendee to an event
  1. tell application "Calendar"
  2. tell calendar "Project Calendar"
  3. set theEvent to (first event where its summary = "Important Meeting!")
  4. tell theEvent
  5. make new attendee at end of attendees with properties {email:"example@apple.com"}
  6. end tell
  7. end tell
  8. reload calendars
  9. end tell

JAVASCRIPT

Open in Script Editor

Listing 12-2JavaScript: Adding an attendee to an event
  1. var app = Application.currentApplication()
  2. var Calendar = Application("Calendar")
  3. var projectCalendars = Calendar.calendars.whose({name: "Project Calendar"})
  4. var projectCalendar = projectCalendars[0]
  5. var events = projectCalendar.events.whose({summary: "Important Meeting!"})
  6. var event = events[0]
  7. var attendee = Calendar.Attendee({email: "example@apple.com"})
  8. event.attendees.push(attendee)
  9. Calendar.reloadCalendars()