私はAppleScriptを実行して、上司の受信トレイにあるすべてのメッセージからすべての電子メールアドレスを抽出していますが、上司のコンピューターでフリーズし、私の場合は正常に機能します。
私のコンピューターはメール4.6でSnowleopardを実行しており、違いがあれば彼はメール5.3でLionを実行しています。
また、私は通常メールを使用せず、スクリプトをテストするためにそれらのメッセージのみを取得し、彼のメール数は60 000を超えているため、受信トレイには約400通のメールしかありません。
スクリプトは約20秒で私の電子メールを実行し、彼は40を実行するのに2分かかり、その後フリーズしました。
彼の上位バージョンでコードがフリーズする原因となる可能性のあるコードに何か問題があるのか、または存在する電子メールの増加が原因であるのか疑問に思いました。
別の注意点として、私がこれを適応させたスクリプトは、ファイルに書き込む前にアドレスを並べ替えて重複を削除することであったため、それらをすべて1つずつ書き込むことはおそらく逆効果であることを知っていますが、メールの数が多いため、プロセスを高速化し、書き込みに使用するメモリを減らします。PLusカウンターは、スクリプトがどこにあるかを知るのに役立ちます。
ここにコードがあります:
tell application "Finder" to set ptd to path to documents folder as string
    set theFile to ptd & "extracted3.txt"
    set theFileID to open for access theFile with write permission
set counter to 0
tell application "Mail"
    set selectionMessage to selection -- just select the first message in the folder
    set thisMessage to item 1 of selectionMessage
    set theseMessages to (every message in (mailbox of thisMessage))
    repeat with eachMessage in theseMessages
        try
            set counter to counter + 1
            set theFrom to (extract address from sender of eachMessage)
            set theFromName to (extract name from sender of eachMessage)
            set theFromTemp to theFrom & "," & theFromName & "," & counter
            write theFromTemp & return to theFileID as «class utf8»
            if (address of to recipient) of eachMessage is not {} then
                repeat with i from 1 to count of to recipient of eachMessage
                    set theTo to (address of to recipient i) of eachMessage as string
                    set theToName to (name of to recipient i) of eachMessage as string
                    set theToTemp to theTo & "," & theToName & "," & counter
                    write theToTemp & return to theFileID as «class utf8»
                end repeat
            end if
            if (address of cc recipient) of eachMessage is not {} then
                repeat with i from 1 to count of cc recipient of eachMessage
                    set theCC to (address of cc recipient i) of eachMessage as string
                    set theCCName to (name of cc recipient i) of eachMessage as string
                    set theCCTemp to theCC & "," & theCCName & "," & counter
                    write theCCTemp & return to theFileID as «class utf8»
                end repeat
            end if
        end try
    end repeat
end tell
close access theFileID