使用Applescript编辑转发邮件的主题 - 编辑主题行时遇到错误

时间:2016-04-19 19:20:06

标签: email applescript osx-elcapitan

我一直在尝试编写一些Applescript来转发邮件并编辑主题。目前我正在致力于转发和填充收件人和主题。

当我运行它时,它给了我错误:

"Mail got an error: Can't set subject of item to any."

以下是代码:

tell application "Mail"
    set theSelection to selection
    set theForwardedMessage to forward (item 1 of theSelection) with opening window
    tell theForwardedMessage
        make new to recipient with properties {address:"address@blahblah.com"}
        set subject to "blahblahblah"
    end tell
end tell

我无法弄清楚为什么它告诉我它无法编辑主题。有什么指针吗?

1 个答案:

答案 0 :(得分:0)

我希望这会有所帮助,但我不完全理解你的剧本和问题。

set recipientName to "ZWEKKERBOY"
set recipientAddress to "john@doe.com"
set theSubject to "Subject here"
set theContent to "Content"

--Mail Tell Block
tell application "Mail"

--Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}

    --Set a recipient
tell theMessage
        make new to recipient with properties {name:recipientName, address:recipientAddress}

    --Send the Message
    send

end tell
end tell

- 对制造商的信任!

您可以更改

set theSubject to "Subject here"

线

set theSubject to subject
-- that's "blahblahblah"