Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mieslep

macrumors newbie
Original poster
Oct 12, 2012
2
0
I am trying to get a set of Address Book "person" objects for those people with e-mails containing a specific string (e.g. "somedomain.com").

As a proof of concept:

Code:
tell application "Address Book"
  repeat with thePerson in (every person where the value of its email contains "somedomain.com")
    display dialog "first=" & (first name of thePerson) & " last=" & (last name of thePerson)
  end repeat
end tell

However, this search doesn't work...and I can't figure out why not! I can search for people with "first name" and such, it seems to be related to not correctly be searching into the "emails" collection. "where the value of its first email" does return a result, but isn't functionally what I want to do...
 
The contains and is contained by operators work with lists, records, and text objects.

Don't know if this will help you but you can give it a try.

Code:
property theFirstName : ""
property theLastName : ""
tell application "Address Book"
	repeat with thePerson in every person
		if (the value of thePerson's email as string) contains "somedomain.com" then
			set theFirstName to thePerson's first name
			set theLastName to thePerson's last name
			my displayDialog()
		end if
	end repeat
end tell
on displayDialog()
	display dialog "first=" & theFirstName & " last=" & theLastName
end displayDialog
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.