2015-12-02 59 views
0

我有一個AppleScript,它會回覆具有特定文本的角色郵件。AppleScript回覆回覆地址

on run {input, parameters} 

    set myReply to "My Text" 

    tell application "Mail" 
     set theSelection to selection 
     if theSelection is {} then return 
     activate 
     repeat with thisMessage in theSelection 
      set theOutgoingMessage to reply thisMessage with opening window 
      repeat until exists (window 1 whose name = "Re: " & subject of thisMessage) 
      end repeat 
      delay 0.3 

      tell application "System Events" 
       keystroke myReply 
      end tell 

      delay 0.5 
      send theOutgoingMessage 
     end repeat 
    end tell 

    return input 
end run 

問題是它總是回覆發件人地址而不是回覆地址。

我在哪裏可以將地址設置爲回覆地址?

回答

1

通常,回覆消息默認使用回覆地址。可能你有特殊的電子郵件....?無論如何,爲了強制使用回覆,你需要在回覆之前從thisMessage讀取它,然後分配它。

您不需要測試選擇是否爲{}:如果它是空的,重複循環將不會啓動。

另外,我不建議使用按鍵(總是很危險),而是直接將回覆電子郵件的內容設置爲文本值。

見腳本波紋管與變化建議(測試OK):

set myReply to "My Text" 

tell application "Mail" 
activate 
set theSelection to selection 
repeat with thisMessage in theSelection 
    set ReplyAddress to reply to of thisMessage 
    set theOutgoingMessage to reply thisMessage with opening window 
    repeat until name of front window is (subject of theOutgoingMessage) 
     delay 0.3 
    end repeat 

    set content of theOutgoingMessage to (myReply) as rich text 
    set A to to recipient 1 of theOutgoingMessage 
     set address of to recipient 1 of theOutgoingMessage to ReplyAddress 
end repeat 
end tell 
+0

完美的作品!只是在'end repeat'前添加'send theOutgoingMessage'來觸發發送 – Xaver