I get a class error
Can't set «class az21» 1 of "David Baxter" to
Why? Because in Address Book 'email' is an element of 'person' , not a property. You are trying to set a string to this element, which won't work. The 'email' element has its own properties. Take a look at this script that I think might be relevant:
-- set firstName to "Peter" set lastName to "Baxter"
tell application "Address Book" -- Get a list of all person records with this name. set myPeople to (people whose first name is equal to firstName and last name is equal to lastName) -- If one item is returned. if (count myPeople) contains 1 then -- Add an email to that person make new email at the end of emails of (item 1 of myPeople) with properties {value:theAddress} -- If more than one item is returned. else if (count myPeople) is greater than 1 then -- Show a dialog about the multiple items - none will be changed. display dialog "You have multiple entries with the name " & return & firstName & " " & lastName & "." -- If count of returned items is less than one, add a new person. else set myPerson to make new person with properties {first name:firstName, last name:lastName} make new email at the end of emails of myPerson with properties {value:theAddress} end if save addressbook end tell --
Best wishes
John Maisey www.nhoj.co.uk
|