PDA

View Full Version : Applescript - add attendees (from Address Book to iCal event)




phil.black
Apr 13, 2009, 03:44 PM
Hello scripting gurus!!! (Help, please...)

I've looked through various forums, but can't find a COMPLETE solution to what I believe should be a fairly straightforward problem. I'll start by asking the question as concisely as I can, then bring in more information about what I have tried, and learned, so far. I'll also outline my broad (mini) project aims at the end, just in case anyone is interested.

*** Q: How can I add attendees, from my Address Book, to an iCal event, so that ***ALL*** the attendee details are included?

Note: It is VITAL to me that attendees' phone number(s) are available through iCal, not just {display name, email, participation status}. This is because I want MobileMe to synch the event with my iPhone, so I can call attendees directly from iCal. (or at least have iCal open the attendee's Contacts record so I can call from there!)

WHY DO I THINK IT SHOULD BE POSSIBLE?

Manually, I can simply dbl-click on the event, click into the attendees field, start typing the attendee name, and hit enter. When I do this, it works. MobileMe synchs it to the iPhone, I open iCal, select the event, tap the attendee, and I'm calling.

WHAT I'VE TRIED USING APPLESCRIPT

When I try the following script, I've only managed to set Sheila's name/email/participation status. I can retrieve her phone number from Address Book using the above approach, but unsure how to make it stick in iCal *** such that I am able to use it to call directly from iCal on the iPhone ***

++++++++++++++++++++++++

tell application "Address Book"
set anAttendee to name of (first person whose name contains "Sheila")
end tell

tell application "iCal"
set newEvent to make new event at end with properties
{summary:"Meeting Info.", location:"ZIP", description:"More yak", start date:SD, end date:SD + 120 * minutes}
make new attendee at end of attendees of newEvent with properties {display name:anAttendee}
end tell

++++++++++++++++++++++++


WHERE I'VE LOOKED FOR SIMILAR EXAMPLES

Thanks to Rob (et al) for providing script examples used to create the above, see here: http://macscripter.net/viewtopic.php?id=5692

I've also looked at the following article, which makes me think I somehow need to use the PERSON ID in the event attendee list. Unfortunately, I have only managed to retrieve the ID, but had no joy trying to set it.

http://www.mactech.com/articles/mactech index.html

THE PROJECT

I'm a surveyor, and using dialog(s) to enter relevant info., I'm looking to streamline my preparation for surveys when I make each new appointment.

My mini-project presently enables me to print survey forms (based on a Pages template) with details relating to the specific property (address/contact name&no./appointment date&time etc.) It also uses the appointment date&time to create the appropriate event in iCal.

I'm also confident I can add the contact details, such as agent/owner name(s) and phone number(s) in Address Book.

IF I COULD ONLY ADD THESE AS ATTENDEE(S), AS IF ADDED MANUALLY, I WOULD ALSO BE ABLE TO PHONE THE PROPERTY OWNERS WITH A COURTEOUS REMINDER WHEN I'M ON THE WAY!!

Can anyone help me achieve this?
Here's hoping.
Phil (wiimixer)