设置外发消息内容失败

Setting the content of an outgoing message fails

我试图创建一个自动回复脚本,但当我尝试设置外发消息的内容时,它抛出一个错误并告诉我无法读取 "content"。

set replyMessage to reply thisMessage with opening window
delay 2
set rich text content of replyMessage to "Hallo"

有什么想法吗?

编辑:完整代码:

tell application "Mail"
    set replyList to {}
    set inboxMessages to every message in inbox

    # get Einsatz mail from all emails
    repeat with thisMessage in inboxMessages
        set thisContent to content of thisMessage
        set thisSender to sender of thisMessage

        if thisSender contains "@pos-lifestyle.de" then
            if thisContent contains "nochmal alle wichtigen Informationen zum Heimspiel" then
                if thisContent contains "deinen Einsatz per Mail" and thisContent contains "Bitte bestätige" then
                    set end of replyList to thisMessage
                    set read status of thisMessage to true
                end if
            end if
        end if
    end repeat


    # reply to all Einsatz mails
    repeat with thisMessage in replyList
        set replyMessage to reply thisMessage with opening window
        delay 2
        set content of replyMessage to (("Hallo," & return & "hiermit bestätige ich den Einsatz." & return & "Mit besten Grüßen" & return & "Max Mustermann") as rich text)
    end repeat
end tell

我现在根据您的最新更新完成完整的脚本。 我用几个案例测试了它,它 100% 为我工作。我只是做了一些简化。 此外,我在脚本顶部设置了目标(发件人和内容),以使其更易于阅读和测试(为了测试,我只需要更改顶部 4 行的值以及来自我的邮箱的可能值!)。

set TargetSend to "@pos-lifestyle.de"
set Target1 to "nochmal alle wichtigen Informationen zum Heimspiel"
set Target2 to "deinen Einsatz per Mail"
set Target3 to "Bitte bestätige"

tell application "Mail"
set replyList to {}
set inboxMessages to every message in inbox whose sender contains TargetSend
repeat with thisMessage in inboxMessages
    set thisContent to content of thisMessage
    if (thisContent contains Target1) and (thisContent contains Target2) and (thisContent contains Target3) then
        set end of replyList to thisMessage
        set read status of thisMessage to true
    end if
end repeat

# reply to all Einsatz mails
repeat with thisMessage in replyList
    set replyMessage to reply thisMessage with opening window
    delay 2
    set content of replyMessage to (("Hallo," & return & "hiermit bestätige ich den Einsatz." & return & "Mit besten Grüßen" & return & "Max Mustermann") as rich text)
end repeat
end tell

我想出了一个方法来防止这个错误发生

set TargetSend to "@pos-lifestyle.de"
set Target1 to "nochmal alle wichtigen Informationen zum Heimspiel"
set Target2 to "deinen Einsatz per Mail"
set Target3 to "Bitte bestätige"
set MyName to "Max Musterman"

tell application "Mail"
    set replyList to {}
    set inboxMessages to every message in inbox whose sender contains TargetSend

    # look for Einsatz mails
    repeat with thisMessage in inboxMessages
        set thisContent to content of thisMessage
        if (thisContent contains Target1) and (thisContent contains Target2) and (thisContent contains Target3) then
            set end of replyList to thisMessage
            set read status of thisMessage to true
        end if
    end repeat

    # reply to all Einsatz mails
    repeat with thisMessage in replyList
        set replyMessage to reply thisMessage with opening window
        repeat until exists (window 1 whose name = "Re: " & subject of thisMessage)
        end repeat
        delay 0.1

        tell application "System Events"
            tell process "Mail"
                set frontmost to true
                keystroke "Hallo"
                keystroke return
                keystroke "Hiermit bestätige ich den Einsatz."
                keystroke return
                keystroke "Mit besten Grüßen"
                keystroke return
                keystroke MyName
                keystroke return
            end tell
        end tell

        #send replyMessage

    end repeat
end tell