I want to work with a list of all email addresses that appear in my address book. I thought I could simply set
such a list with AppleScript, and use the elements, maybe after casting the references to strings, as this answer suggests. However, the code below runs into a casting error, with or without explicit casting (e.g. as string
):
error "Can’t make «class az21» 1 of «class azf4» id \"C74972A5-88D4-4B0F-8DEA-304914926EE6:ABPerson\" of application \"Contacts\" into the expected type." number -1700 from «class az21» 1 of «class azf4» id "C74972A5-88D4-4B0F-8DEA-304914926EE6:ABPerson"
tell application "Contacts"
set allEmails to every email of every person
end tell
repeat with anEmail in allEmails
display dialog anEmail
end repeat
This problem, of course, also inhibits any more meaningful uses of the email addresses.
What is this about, and what is a workable way to collect and access all email addresses in my address book?
I am running Public Beta 5 of El Capitan, though I did not test whether the behavior is any different on older (= actual) releases.