Pure X
Pure X

Reputation: 13

AppleScript to set "my card" to a defined name or e-mail address in Contacts under OS X 10.12.3

First i must say sorry for my bad english. I come from Germany and i can't find any help or idea for my problem in different Communitys here.

I look and try to write a little script, which one set my card to the person with email address "johndoe@...", or alternatively from the person named "John Doe" Both is ok but i prefer email address.

I hope i can find some help here.

This only one script, which one i found doesn't work.

tell application "Contacts"
activate
try
set my card to people whose first name is "John" and last name is "Doe"
end try
quit
end tell

Thank's for help and greetings Andy

Upvotes: 0

Views: 121

Answers (2)

Pure X
Pure X

Reputation: 13

tell application "Safari" to activate
tell application "System Events"
    click menu item "Verlauf löschen …" of menu 1 of menu bar item "Verlauf" of menu bar 1 of process "Safari"
    try
        click button "Verlauf löschen" of front window of process "Safari"
    on error
        try
            click button "Verlauf löschen" of sheet 1 of window 1 of process "Safari"
        end try
    end try
end tell
tell application "Safari" to close every window
tell application "Safari"
    make new document with properties {URL:"https://www.startpage.com/deu/#hmb"}
end tell

Upvotes: 0

vadian
vadian

Reputation: 285079

You are pretty close

tell application "Contacts"
    activate
    try
        set my card to 1st person whose first name is "John" and last name is "Doe"
        save
    end try
    quit
end tell

You have to get the 1st person who matches the arguments and you have to save the address book.

Or searching for email

tell application "Contacts"
    activate
    try
        set my card to 1st person whose value of emails contains "[email protected]"
        save
    end try
    quit
end tell

Upvotes: 1

Related Questions