Adding an Alarm to an Event
Calendar events can contain alarms that display messages, send emails, and play sounds. Listing 11-1 and Listing 11-2 show how to add alarms to an event. Each example adds two alarms—a message alarm and a message-with-sound alarm.
APPLESCRIPT
tell application "Calendar"
tell calendar "Project Calendar"
set theEvent to (first event where its summary = "Important Meeting!")
tell theEvent
-- Add a message alarm
make new display alarm at end of display alarms with properties {trigger interval:-5}
-- Add a message with sound alarm
make new sound alarm at end of sound alarms with properties {trigger interval:-5, sound name:"Sosumi"}
end tell
end tell
reload calendars
end tell
JAVASCRIPT
var app = Application.currentApplication()
var Calendar = Application("Calendar")
var projectCalendars = Calendar.calendars.whose({name: "Project Calendar"})
var projectCalendar = projectCalendars[0]
var events = projectCalendar.events.whose({summary: "Important Meeting!"})
var event = events[0]
// Add a message alarm
var displayAlarm = Calendar.DisplayAlarm({triggerInterval: -5})
event.displayAlarms.push(displayAlarm)
// Add a message with sound alarm
var soundAlarm = Calendar.SoundAlarm({triggerInterval: -5, soundName: "Sosumi"})
event.soundAlarms.push(soundAlarm)
Calendar.reloadCalendars()
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-09-13