Yes, I tried that already:
set peopleToCheck to every person where ((label of its emails contains strContactEmailLabelHome))
Returns an empty set.
At least it runs really fast! Actually, it seems too fast to have actually done a query. This speed got me thinking and I tried a lot of simple hacks before hitting on this one:
set peopleToCheck to every person where (label of its emails contains "email")
Returns a set of three.
Looking at the returned set, this query is matching when the entire label is exactly “email”; the query disregards contains
and is matching on is
.
Turns out that custom labels are in the format:
_$!<
theLabel>!$_
Yes, theLabel is prefixed by _$!< and suffixed by >!$_; for some reason, contains
is not disregarding the prefix and suffix before doing its comparison.
Emails without a custom label do have a label and it is Email
; note the capital letter. Fortunately, I had my query surrounded by ignoring case
so it matched my lowercase search criteria.
Of the three people who matched, one had an email with the label _$!<work>!$_
So, putting this all together, I tried:
set peopleToCheck to every person where (label of its email contains "_$!<work>!$_")
It runs for almost three seconds but returns an empty set. How can this be; there are hundreds—perhaps thousands—of email addresses labeled “work” in my Contacts.
I’m out of ideas.
What do you suggest trying to query people based on the custom labels of their email addresses?
UPDATE Wednesday, June 1, 2022 7:57 PM
By the way, this query also returns an empty record set:
set peopleToCheck to every person where (label of its custom dates contains "anniversary")
So the problem with custom labels is not restricted to emails.