【发布时间】:2011-07-23 19:48:08
【问题描述】:
我正在尝试创建一个“遍历”邮箱的脚本,检查通讯簿以查看电子邮件的发件人是否已经存在,并将联系人添加到通讯簿组(如果找到)。如果未找到电子邮件的发件人,则会在将其添加到组之前创建一个新联系人。
到目前为止,我已经为组添加部分准备了这个:
on addPersonToGroup(person)
tell application "Address Book"
add person to group "wedding guests"
end tell
save addressbook
end addPersonToGroup
这用于循环选择消息:
tell application "Mail"
set selectedMessages to selection
if (count of selectedMessages) is equal to 0 then
display alert "No Messages Selected" message "Select the messages you want to add to 'wedding guests' address book group before running this script."
else
set weddingGuests to {}
repeat with eachMessage in selectedMessages
set emailAddress to extract address from sender of eachMessage
--if emailAddress is found in Address Book then
-- get the person from the Address Book
--else
-- create new person with emailAddress
--end if
--addPersonToGroup person
end repeat
end if
end tell
“repeat with eachMessage ...”块中被注释掉的部分是我还没有弄清楚的。
有哪些方法可以使用 AppleScript 在通讯簿中搜索电子邮件地址? Mac 上是否有更适合此类任务的替代脚本语言?
【问题讨论】:
标签: email applescript addressbook