什么“无法将应用程序'地址簿'纳入类型位置参考,”是什么意思?为什么我的代码不起作用?

时间:2012-09-30 18:07:05

标签: applescript

我正在尝试在Applescript中创建与已经填写的信息进行新联系的代码。这是我的代码:

set contactFirstName to "Brandon"
set contactLastName to "Damante"
set contactStreet to "7688 Somerly Ct"
set contactCity to "New Albany"
set contactCountry to "USA"
set contactZip to "43054"
set contactEmail to "chocolatecheese101@hotmail.com"
set contactNote to "I'm Awesome"
set contactState to "Ohio"
--Address Book Tell Block
tell application "Address Book"
    --Create the Contact
    set theContact to make new name with properties {first name:contactFirstName, last     name:contactLastName, street:contactStreet, city:contactCity, state:contactState,     country:contactCountry, zip:contactZip, email:contactEmail, note:contactNote}
end tell

它突出显示粗体部分,并说:“无法将应用程序'地址簿'转换为类型位置参考,”我以前从未见过该错误消息。这对我的代码意味着什么?我怎么能纠正它?

1 个答案:

答案 0 :(得分:1)

试试这个:

set contactFirstName to "Brandon"
set contactLastName to "Damante"
set contactStreet to "7688 Somerly Ct"
set contactCity to "New Albany"
set contactCountry to "USA"
set contactZip to "43054"
set contactEmail to "chocolatecheese101@hotmail.com"
set contactNote to "I'm Awesome"
set contactState to "Ohio"
--Address Book Tell Block
tell application "Address Book"
    set theContact to make new person at end of people with properties {first name:contactFirstName, last name:contactLastName, note:contactNote}
    tell theContact
        make new address at end of addresses with properties {street:contactStreet, city:contactCity, state:contactState, country:contactCountry, zip:contactZip, label:"Work"}
        make new email at end of emails with properties {label:"Work", value:contactEmail}
    end tell
    save
end tell