Следующий яблочный скрипт работает для меня, но я не уверен, как выполнить сопоставление регулярному выражению. Вы можете использовать unix-функцию «grep» с командой «do shell script
» appleScript, но я не специалист в том, как правильно использовать grep. Я оставлю это для того, чтобы кто-то другой ответил.
on run
tell application "Mail"
set myInbox to mailbox "INBOX" of account 1
set myMessages to every message of myInbox
repeat with theMessage in myMessages
if read status of theMessage is false then
if my subjectIsInteresting(subject of theMessage) then
open theMessage
delay 4
close window 1
end if
end if
end repeat
end tell
end run
on subjectIsInteresting(subject)
-- do some regex magic here
return true -- for now
end subjectIsInteresting