Re: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
Re: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
- Subject: Re: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
- From: Jim Underwood <email@hidden>
- Date: Fri, 21 Jul 2017 23:30:58 +0000
- Thread-topic: Get List of Contact Names and Associated EMails for EMail Addresses that contain a string
Axel,
Thanks for the script. Always good to see another approach.
Unfortunately, this script seems to produce a duplicate list item if the person
has more than one email:
[cid:EF1F070C-45F1-407E-BFF2-9A183E498F19]
I'm sure this could be easily fixed, I just haven't taken the time to do so.
I'd encourage you to post your solution in the original thread at
http://forum.latenightsw.com/t/how-do-i-search-contacts-for-string-in-email-address/676
Best Regards,
Jim Underwood
aka JMichaelTX
From: Axel Luttgens <email@hidden<mailto:email@hidden>>
Reply-To: "ASUL (AppleScript)"
<email@hidden<mailto:email@hidden>>
Date: Friday, July 21, 2017 at 6:06 PM
To: "ASUL (AppleScript)"
<email@hidden<mailto:email@hidden>>
Subject: Get List of Contact Names and Associated EMails for EMail Addresses
that contain a string
Hello Jim,
http://forum.latenightsw.com/t/how-do-i-search-contacts-for-string-in-email-address/676
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