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: kiwioz on Mar 15, '04 08:10:44AM
Thanks for all who have posted. This is what I have done to work for me.

using terms from application "Address Book"
	on action property
		
		return "address"
	end action property
	
	on action title for p with e
		set theName to (first name of p) & " " & (last name of p)
		return "Schedule meeting with " & 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)
		scheduleMeeting((id of p), theName)
	end perform action
	
end using terms from

on scheduleMeeting(id, personName)
	tell application "iCal"
		
		set callist to my get_cal_titles() (*get cal titles*)
		set selectedcals to (choose from list callist) as Unicode text (*do menu with cal titles*)
		set thecal to first calendar whose title is selectedcals (*identify selected cal in iCal*)
		
		set theItem to (make new event at end of event of thecal)
		set summary of theItem to "Meet with " & personName
		set url of theItem to "addressbook://" & id
		set status of theItem to tentative
		set end date of theItem to (current date) - 250 * minutes as date
		make new display alarm at end of display alarms of theItem with    properties {trigger interval:-15}
		(* 
                set thePerson to (make new attendee at end of attendees of theItem)
                        set display name of thePerson to ("Me" as Unicode text)
                        set email of thePerson to ("me@me.com" as Unicode text)
                *)
		
		activate
		show theItem
	end tell
end scheduleMeeting

on get_cal_titles() (*gets a list of strings of calendar titles*)
	set list_of_cals to {}
	tell application "iCal"
		repeat with aCal in calendars
			set list_of_cals to list_of_cals & (title of aCal as string)
		end repeat
	end tell
	return list_of_cals
end get_cal_titles
Once again thanks to all Craig

[ Reply to This | # ]
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 | # ]