I am trying to work out how I can drag a contact from the address book over onto iCal and create an event with the following details going into the event.
Title: Mr First Name + Last Name, Phone Number
Location: Contacts address + postcode
Please if anybody has any idea please let me know.
many thanks in advance
Model: Mac Mini, OSX 10.6.6
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)
HI, grooveriw. Welcome to MacScripter.
There’s no really satisfactory way to do that, but one possibility is to use a stay-open applet to check your calendar every few seconds for new additions. The script below illustrates the principle. You’ll need to use your own calendar name and decide what to do if the person has more than one address or more than one phone in Address Book.
-- Save this as a stay-open application and start it before dragging anything from Address Book to iCal.
-- Don't drag more than one contact every two seconds!
property olderEventIDs : missing value
on run
tell application "iCal"
launch
set olderEventIDs to uid of events of calendar "Work"
end tell
end run
on idle
tell application "iCal" to set newestEventID to uid of last event of calendar "Work"
if (newestEventID is not in olderEventIDs) then
tell application "iCal"
set newEvent to event id newestEventID of calendar "Work"
set personsName to text from word 3 to -1 of (get summary of newEvent)
end tell
tell application "Address Book"
set client to person personsName
set personsAddress to formatted address of client's first address -- whose label is "home"
set personsPhoneNumber to value of client's first phone -- whose label is "mobile"
end tell
tell application "iCal"
tell newEvent to set {summary, location} to {personsName & return & personsPhoneNumber, personsAddress}
end tell
set end of olderEventIDs to newestEventID
end if
return 2 -- Check again in two seconds' time.
end idle
on quit
set olderEventIDs to missing value
continue quit
end quit