0

このスクリプトは 10.7 以前では動作していましたが、10.8 では壊れているようです。この線:

set theFilePath to ((path to application support from user domain) as rich text) & "AppFolderName:" & UniqueName as string
set theFileReference to open for access theFilePath with write permission

以前のバージョンでは問題なく動作していましたが、Apple が Mountain Lion での正常な動作を妨げているようです。Mountain Lion で Apple スクリプトを介してそのフォルダにアクセスする他の方法はありますか?

編集:メールルール内で、プログラムがインポートできるテキストファイルにメッセージ全体をエクスポートするスクリプトのコード全体を含めました。テキスト ファイルは ~/Library/Application Support/MyProgram/MailImport/ に送信されます。

私の場合と同じように、ディレクトリがマシンに既に存在していることを確認してください。Appleスクリプトはそれをチェックしません。

path to application supportこのスクリプトは、コード内にある場合は機能しませんがpath to desktop、正常に機能するように変更すると、アプリケーション サポート フォルダーへの書き込みに問題がありますが、コードは機能します。

テストするには、Mail で新しいルールを作成し、Every Message でスクリプトを実行します。~/Library/Application Scripts/com.apple.mail/ にスクリプトを配置する必要があります。

その後、ルール ウィンドウにオプションとして表示されます。メッセージを右クリックして [ルールの適用] を選択すると、個々のメッセージでスクリプトをテストできます。

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with eachMessage in theMessages
                set sub to subject of eachMessage
                set mid to message id of eachMessage
                set sen to sender of eachMessage
                set recp to ""
                repeat with thisRecpt in recipients of eachMessage
                    set recp to recp & address of thisRecpt & ","
                end repeat
                set {year:y, month:m, day:d, hours:hh, minutes:mm} to (date sent of eachMessage)
                set dat to (y * 10000 + m * 100 + d) as string
                set tim to (hh * 100 + mm) as string
                set con to content of eachMessage

                set TotalString to "<!STDMessageSubject>" & sub & "<!STDMessageSubject>" & "<!STDMessageID>" & mid & "<!STDMessageID>" & "<!STDMessageSender>" & sen & "<!STDMessageSender>" & "<!STDMessageRecipient>" & recp & "<!STDMessageRecipient>" & "<!STDMessageDate>" & dat & "<!STDMessageDate>" & "<!STDMessageTime>" & tim & "<!STDMessageTime>" & "<!STDMessageContent>" & con & "<!STDMessageContent>"

                set UniqueName to do shell script "uuidgen"

                set theFilePath to ((path to application support from user domain) as rich text) & "MyApplication:MailImport:" & UniqueName as string
                set theFileReference to open for access theFilePath with write permission


                write TotalString to theFileReference
                close access theFileReference
            end repeat
        end tell
    end perform mail action with messages
end using terms from
4

2 に答える 2

0

したがって、サンドボックスの問題であることが判明しました。10.8 の Apple Mail は、取得しようとするのがどれほど難しいかに関係なく、一般に Sandboxed Application Support フォルダの場所を使用する~/Library/Application Support/ため、10.8 の Mail 内の AppleScript から

path to application support from user domain

パスを返します

~/Library/Containers/com.apple.mail/Data/Library/Application Support/

そこからMyApplication:MailImport:フォルダを作成してアクセスできます。出力を読み取ろうとしている実際のプログラムはサンドボックス化されていないため、問題なく動作しているように見えるので、今のところその場所からデータを読み取ってアクセスできます。

于 2012-10-01T20:10:06.067 に答える