• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Address book
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Address book


  • Subject: Re: Address book
  • From: John M <email@hidden>
  • Date: Sun, 29 Jul 2007 16:40:15 +0100

HI Peter,


On 29 Jul 2007, at 08:29, email@hidden wrote

   I get a class error

Can't set «class az21» 1 of "David Baxter" to  
"email@hidden"

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 theAddress to "email@hidden"
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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Address book
      • From: Peter Baxter <email@hidden>
  • Prev by Date: Re: GUI Scripting to toggle "Announce Time"?
  • Next by Date: Re: AppleScript and shell scripting
  • Previous by thread: Address book
  • Next by thread: Re: Address book
  • Index(es):
    • Date
    • Thread