The following works to create a new event for today but what do I use in place of “set theDate to current date” if I want to use a specific start date (such as May 27, 2008) rather than the current date?
tell application “iCal”
tell calendar “My Calendar”
set theDate to current date
make new event at end with properties {description:“Event Description”,
summary:“Event Name”, location:“Event Location”, start date:theDate,
allday event:true}
end tell
end tell
Goes like this: You make the new event at the end of events, and you specify both a start and a stop date and time if it’s not allday. Otherwise just a date and allday property.
set now to current date
tell application "iCal"
tell calendar "Medical"
make new event at end of events with properties {summary:"A Test", start date:date "Friday, May 16, 2008 12:00:00 AM", allday event:true}
end tell
end tell
Thanks for the quick helpful reply! I have got it working now.
One more problem.
When I use a variable for the date the script doesn’t work. For example if I use:
on run {theCal, eventName}
tell application "iCal"
tell calendar theCal
--set theDate to "Friday 16 May 2008 16:00:00"
make new event at end of events with properties {summary:eventName, start date:date "Friday 16 May 2008 16:00:00"}
end tell
end tell
end run
It works.
But if I use
on run {theCal, eventName}
tell application "iCal"
tell calendar theCal
set theDate to "Friday 16 May 2008 16:00:00"
make new event at end of events with properties {summary:eventName, start date:date theDate}
end tell
end tell
end run
It doesn’t work.
This is a problem since I want to be able to pass the date/time to the script as a parameter along with theCal and eventName.
Did you ever get an answer to setting a variable date for then iCal now Calendar app?