如何使用applescript打开电子邮件?

use*_*780 5 applescript email-integration

我正在写一个小的applescript,它在查看器中检索所有"未读"的消息并循环它们.

我有两个目标需要完成:

  1. 我需要获取每条消息的主题并执行正则表达式以查看它是否适合第2步(例如:使用主题{.*}获取电子邮件)

  2. 我需要在一个单独的窗口打开每条消息,4秒后,我需要关闭该窗口并继续下一条消息

你知道怎么做吗?

提前致谢.

e.J*_*mes 2

以下 applescript 对我有用,但我不确定如何进行正则表达式匹配。您可以将 unix 'grep' 函数与 applescript 的 ' do shell script' 命令一起使用,但我不是如何正确使用 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
Run Code Online (Sandbox Code Playgroud)