Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Schedule iCal meetings from Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Schedule iCal meetings from Address Book
Authored by: marook on Mar 15, '04 06:42:59PM
Hi All, Just updated this action a bit,
1: It's localizable. Edit the text properties in the top!
2: It's only possible to choose a EDITABLE calendar!
3: It's only possible to choose ONE calendar.
4: Property for Alarm default time.

Note: Example translation in Danish shown.


property titlePrefix : "Opret Begivenhed med " --"Schedule Event With "
property meetingPrefix : "Møde med " --"Meet with "
property selectCalPromt : "Opret Møde i Kalender:" -- "Create Event in Calendar:"
property alarmTrigger : -15 (*Minus is BEFORE event, Plus is AFTER the event! *)

using terms from application "Address Book"
	on action property
		return "email"
		--return "phone"
		--return "address"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return titlePrefix & theName
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		set theName to (first name of p) & " " & (last name of p)
		my scheduleMeeting(theName, (id of p), (value of e))
	end perform action
	
end using terms from


on scheduleMeeting(personName, theid, theEmail)
	tell application "iCal"
		
		set callist to {}
		repeat with aCal in calendars
			if aCal is writable then set callist to callist & (title of aCal as string)
		end repeat
		activate
		set selectedcal to (choose from list callist with prompt selectCalPromt without empty selection allowed and multiple selections allowed) as Unicode text (*do menu with cal titles*)
		set thecal to first calendar whose title is selectedcal (*identify selected cal in iCal*)
		
		set theItem to (make new event at end of events of thecal with properties ¬
			{summary:meetingPrefix & personName, url:"addressbook://" & theid, status:tentative, start date:((current date) + 60 * minutes as date), end date:((current date) + 120 * minutes as date)})
		
		tell theItem
			make new display alarm at beginning of display alarms with properties {trigger interval:alarmTrigger}
			make new attendee at beginning of attendees with properties {display name:personName, email:theEmail}
		end tell
		
		show theItem
	end tell
end scheduleMeeting

Enjoy!

---
/Marook

[ Reply to This | # ]