MacOS – Add to Existing Contact from Mail.app to Contacts.app

contactsmacmacosmail.app

I am looking for an option to add the choice "Add to Existing Contact" from the Apple Mail.app From address field. As you all know, we have "Copy Address, Add to VIPs, New Email, Add to Contacts, and Services" as current choices. I am hoping that I can find a way to have an additional choice of "Add to Existing Contact" to this list – maybe listed under Services.

I know that this is a choice when you use the smart detection feature from a signature. I also know this is an option in iOS 6. So how can I get the same functionality for From: addresses in Mail.app?

Best Answer

This is a quick look at this,. which means it can either be refined or there is a better answer.

I will assume you know how to create an automator service. So here is an image showing the setup.

enter image description here

Applescript 1:

on run {input, parameters}
    set bigList to {}
    tell application "Contacts"

        repeat with i from 1 to number of items in input
            set this_item to item i of input
            copy name of this_item to end of bigList
        end repeat
    end tell
    return bigList
end run

Applescript 2:

on run {input, parameters}
    tell application "Mail"
        set eachMessage to item 1 of (get selection)
        set theExtractAddress to extract address from (sender of eachMessage)
    end tell
    tell application "Contacts"
        set thisPerson to first person whose name is item 1 of input

        make new email at end of emails of thisPerson with properties {label:"home", value:theExtractAddress}
        save
    end tell

end run

It will ask for permission to access the Addressbook the first time you run it. And is a bit slow to return the search results. but worked in my test.