AppleScript 仲間への質問です。AppleScript Editor または Script Debugger で実行すると問題なく実行される次のスクリプトがありますが、メール ルールから実行しようとするとまったく実行されません。スクリプトは ~/Library/Application Scripts/com.apple.mail に正しく配置され、メール ルールの [AppleScript の実行] メニューに表示されますが、新しいメールが到着すると単に動作を拒否します。
on perform_mail_action(info)
tell application "Mail"
set theMessages to |SelectedMessages| of info
repeat with thisMessage in theMessages
set AppleScript's text item delimiters to {""}
set thisSender to sender of thisMessage as string
set quotepos to offset of "\"" in thisSender
if (quotepos is not 0) then
set thisSender to (text items (quotepos + 1) through -1) ¬
of thisSender as string
set quotepos to offset of "\"" in thisSender
if (quotepos is not 0) then
set thisSender to (text items 1 through (quotepos - 1)) ¬
of thisSender as string
end if
else
set atpos to offset of "@" in thisSender
if (atpos is not 0) then
set thisSender to (text items 1 through (atpos - 1)) ¬
of thisSender as string
end if
set brkpos to offset of "<" in thisSender
if (brkpos is not 0) then
set thisSender to (text items (brkpos + 1) through -1) ¬
of thisSender as string
end if
end if
tell application "Finder" to say "Mail from " & thisSender
end repeat
end tell
end perform_mail_action
何か案は?