Applescript not returning emails for Contacts - people
I am not sure why this isn't working as it retrieves people where I know there are emails associated with most of the people in contacts:
on cleanval(val)
local oval
set oval to null
if val is not equal to missing value then
set oval to val
end if
return oval
end cleanval
tell application "Contacts"
local results, cloop, ident
set results to {}
local G__6588
set G__6588 to people -- whose (first name contains "Frank")
repeat with G__6587 in G__6588
set cloop to properties of G__6587
set ident to {primary_department:null, first_name:null, name_suffix:null, middle_name:null, primary_company:null, primary_title:null, last_name:null, full_name:null}
set primary_department of ident to my cleanval(department of cloop)
set first_name of ident to my cleanval(first name of cloop)
set name_suffix of ident to my cleanval(suffix of cloop)
set middle_name of ident to my cleanval(middle name of cloop)
set primary_company of ident to my cleanval(organization of cloop)
set primary_title of ident to my cleanval(job title of cloop)
set last_name of ident to my cleanval(last name of cloop)
set full_name of ident to my cleanval(name of cloop)
local elist, eadd
set elist to {}
repeat with eml in (get emails of cloop)
set eadd to {email_type:null, email_address:null}
set email_type of eadd to my cleanval(label of eml)
set email_address of eadd to my cleanval(value of eml)
set end of elist to eadd
end repeat
set ident to ident & {email_list:elist}
set end of results to ident
end repeat
return results
end tell
MacBook Pro (Retina, 15-inch, Mid 2014), OS X Yosemite (10.10.3), null