1
有沒有更有效的方式來確定聯繫人沒有比這存在:搜索Outlook聯繫人mdfind
set theAddress to "[email protected]"
set found to false
repeat with aContact in contacts
if email addresses of aContact contains theAddress then
set found to true
exit repeat
end if
end repeat
if not found then
...
end if
這將創建一個新的聯繫人,如果沒有找到(和返回true
):
set found to open contact email address "[email protected]"
**編輯**
Search Outlook contacts by category建議我應該能夠做到這一點使用聚光燈查詢:
-- the address to be found
set theEmailAddress to "[email protected]"
-- search identity folder
set currentIdentityFolder to quoted form of POSIX path of (current identity folder as string)
--perform Spotlight query
set theContacts to words of (do shell script "mdfind -onlyin " & currentIdentityFolder & " 'kMDItemContentType == com.microsoft.outlook14.contact && [metadata element that represents an email address] == " & theEmailAddress & "' | xargs -I % mdls -name com_microsoft_outlook_recordID '%' | cut -d'=' -f2 | sort -u | paste -s -")
-- process results
...
代表聯繫人電子郵件地址的元數據元素是什麼?