AppleScript 回复回复地址

AppleScript to reply to reply-to address

我有一个 AppleScript,它用特定文本回复 ceratin 邮件。

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

问题是它总是回复发件人地址而不是回复地址。

在哪里可以设置回复地址?

通常,回复邮件默认使用回复地址。也许你有特殊的电子邮件......?反正要强制使用reply-to,需要在reply之前从thisMessage中读取,然后赋值。

如果selection是{}则不需要测试:如果为空,repeat循环将不会开始。

此外,我建议不要使用击键(总是很危险),而是直接将回复电子邮件的内容设置为您的文本值。

请参阅下面的脚本以及建议的更改(已测试并正常):

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