Applescript to find all occurencies of a eMail address in Outlooks 2011 Contacts and replace.

set oldaddress to ""
set newaddress to ""

tell application "/Applications/Microsoft Office 2011/Microsoft"
    set currentIdentityFolder to quoted form of POSIX path of (current identity folder as string)
    set theContactIDs to words of (do shell script "mdfind -onlyin " & currentIdentityFolder & " 'kMDItemContentType == && kMDItemEmailAddresses == " & oldaddress & "' | xargs -I % mdls -name com_microsoft_outlook_recordID '%' | cut -d'=' -f2 | sort -u | paste -s -")
    set theContacts to {}
    repeat with thisContactID in theContactIDs
        set theaddresses to email addresses of contact id thisContactID
        repeat with theaddress in theaddresses
            set address of theaddress to newaddress
        end repeat
        set email addresses of (item 1 of contact id thisContactID) to theaddresses
    end repeat
end tell

Leave a Reply

Your email address will not be published. Required fields are marked *