• 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
Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get List of Contact Names and Associated EMails for EMail Addresses that contain a string


  • Subject: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 22 Jul 2017 01:06:14 +0200
  • Ironport-phdr: 9a23:2cVP8xwAPe3B67zXCy+O+j09IxM/srCxBDY+r6Qd2+0VIJqq85mqBkHD//Il1AaPBtSLraocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze6/9pnQbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDwULs6Wymt771zRRHolCgJOCQ5/nzZhMJzkqxUrxWvqgdjw47NZYGZKPp+cr/fcN4cWGFPXtxRVytEAo6kc4YOAPQOPeJFpIf7ulsOsQe+BQayC+Pp0T9Dm3j70rc10us/FQHKxgggH88SsHTIo9X6KqESUfuuwanTzjXCb/VW1inh6ITSaR8uv+iBULRtesTfzkkvEhnKjlSWqYH9OzOazPgNvHad7+phWuKvi3Inqxp/ozS12sgsjYzJi4QIwV7H7SV02II4KcCiREJmYtOoDIFcuz+EO4dsXM8uXWVltSAnwbMco5G7ZjIFyJE/yh7abPyIbpaH7wr4VOaUPTd4nHVleK+jhxqq8Uiv1On8Vs6s3VZNsypFjsLMtnEV1xzX7ciHV+Fx8Vmu2DmV0gDT8uVELl4umaXHLJ4hx6Y8lpsVsUvdAi/7gEH7gLKMekk5+eWk9/7rbqv4qpOGKYN4lAXzPrwrmsOlAOQ4NgYOX3Kc+eS5zLDs50L4T6tOjvEslqnZrYzaJdgUpqGnBQ9VyZ0u6w28Dzam1tQXg2UHIEhedx2Zl4TpIU3BIOjkDfejhFShiC1kx+jePr3lHJrNNWTMkK3gfbZl905Q0RczzctB6JJOEbEMO/bzWk7qtNzEFR81KRa7w/7/CNV5yIwSQ36AAqicMPCajVjd7/kya72FfJcRtS32Mfk9+7vzlnIjgncZfLK1xt0ecGi8E7JtJEDPMkDhmtMQLWBftxEjBLjjkEWGXCVYfXeqQ+ch/TwhE6qiDJzfXcakmKSF0WGwGZgANU5cDVXZOGflc82gRusQZy+UOYc1mywJUf6lVpM92hyoryfhyKthI/aS8CBO5sGr78R8++CGzUJ6zjdzFcnIi2w=

> Le 21 juil. 2017 à 01:45, Jim Underwood a écrit :
>
> For those interested in scripting Contacts.app, you might find these scripts
> useful.
> They have had the benefit of some smart, experienced folks over at
> LatenightSW.com (Script Debugger).
>
> Purpose:  Get List of Contact Names and Associated EMails
>                for EMail Addresses that contain a string
>
> First, the version using only native AppleScript, by Mark Alldritt:
> Get List of Contact Name and Associated Emails
>       • This script has a couple of very clever tricks, which Mark calls
> "black magic"  […]

Hello Jim,

I thus looked at the thread you mentioned,
http://forum.latenightsw.com/t/how-do-i-search-contacts-for-string-in-email-address/676,
 especially at your initial request:

        For example, I want to find all Contacts that use a specific
        domain in their email address.
        I need a list of Contact Full Name, with associated emails
        that match.
        […]
        set desiredResult to {¬
        {"John Doe", {"jdoe_home@...", "jdoe_work@..."}}, ¬
        {"Jack Smith", "jsmith@..."}}

I ended with this one, requiring a bit less of black magic, and thus being
perhaps a bit more legible:

        on fetch_contact_names_and_emails_for_domain(_domain)
                local _list, _email, _email_id, _person
                tell application "Contacts"
                        set _list to {}
                        repeat with _email in (emails of people whose value
ends with _domain)
                                set _email_id to id of _email
                                set _person to item 1 of (people whose id of
emails contains _email_id)
                                copy {_person's first name & " " & _person's
last name, value of (emails of _person whose (value ends with _domain))} to the
end of _list
                        end repeat
                end tell
                return _list
        end fetch_contact_names_and_emails_for_domain

        fetch_contact_names_and_emails_for_domain("@gmail.com")

Interestingly, this tends to show that a construct of the form:
        repeat with <variable> in <application generated list of lists>
systematically skips empty elements, regardless of the application being
invoked (see my post "Re : Safari - Bring a tab containing a given URL to the
front", dated May 21).

Axel

 _______________________________________________
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: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
      • From: Jim Underwood <email@hidden>
    • Re: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
      • From: Jim Underwood <email@hidden>
  • Prev by Date: Re: A weird problem scripting Contacts
  • Next by Date: Re: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
  • Previous by thread: Re: Position of an element in a list
  • Next by thread: Re: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
  • Index(es):
    • Date
    • Thread