以下是一个使用AppleScript从列表中创建Mail应用程序的智能收件箱的示例代码:
-- 创建一个空的收件箱列表
set inboxList to {}
-- 获取Mail应用程序的所有收件箱
tell application "Mail"
set allMailboxes to every mailbox
-- 遍历所有收件箱
repeat with i from 1 to count allMailboxes
set thisMailbox to item i of allMailboxes
set mailboxName to name of thisMailbox
-- 判断收件箱名称是否包含关键字
if (mailboxName contains "重要") or (mailboxName contains "优先") then
-- 如果包含关键字,将其添加到收件箱列表中
set end of inboxList to thisMailbox
end if
end repeat
end tell
-- 输出收件箱列表
repeat with i from 1 to count inboxList
set thisInbox to item i of inboxList
set mailboxName to name of thisInbox
display dialog mailboxName
end repeat
这个脚本将遍历Mail应用程序中的所有收件箱,并将名称包含"重要"或"优先"关键字的收件箱添加到一个收件箱列表中。然后,使用display dialog
命令输出收件箱列表中的每个收件箱名称。
你可以根据自己的需求修改关键字和输出方式。