5

I am writing a small applescript which retrieves all "unread" messages in the viewer and loops them.

I have two goals to complete:

  1. I need to get the subject of each message and perform a regular expression to see if it's suitable for step 2 (ex: get emails with subject {.*})

  2. 各メッセージを別のウィンドウで開く必要があり、4 秒後にそのウィンドウを閉じて次のメッセージに進む必要があります

これらの方法を知っていますか?

前もって感謝します。

4

3 に答える 3

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
于 2008-12-24T01:08:28.323 に答える
1

正規表現の場合 - 自分のマシンでスクリプトを実行している場合、またはスクリプトをバンドルして配布できる場合は、Satimage の Smile 拡張機能 ( http://www.satimage.fr/software/en/downloads/index.html ) を使用できます。 Applescript に正規表現を追加します。

于 2009-01-26T03:02:09.550 に答える
1

すでに答えがあることは知っていますが、Automator を調べましたか? このようなほとんどの標準的なスクリプトについては、AppleScript にあまり慣れていない場合でもそれほど苦労することはありません。それはあまり「プログラミング的」ではありませんが、迅速であり、デバッグに費やす時間が少なくなります。

于 2009-06-19T02:13:42.170 に答える