简体   繁体   English

使用AppleScript答复邮件中的选定消息

[英]Using AppleScript to reply to selected message in Mail

First time poster and AppleScript newbie. 第一次海报和AppleScript新手。

I am trying to make an AppleScript which takes the selected mail in mail.app and opens a reply window. 我正在尝试制作一个AppleScript,它将在mail.app中接收选定的邮件并打开一个回复窗口。 In short, I would like it to function exactly like pressing the "reply" button in the mail.app GUI: Open up a reply window and automatically fill the To, Subject, and Body fields. 简而言之,我希望它的功能与在mail.app GUI中按下“答复”按钮时完全相同:打开一个答复窗口,并自动填写“收件人”,“主题”和“正文”字段。

The closest I got was the following: 我得到的最接近的是:

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
    end repeat

end tell

Unfortunately, what this does is create a new reply window for each message in the selected conversation. 不幸的是,这样做是为所选对话中的每个消息创建一个新的回复窗口。 For example: if there are 4 messages in the conversation when I run this script, I get 4 separate reply windows. 例如:如果运行此脚本时对话中有4条消息,则会得到4个单独的回复窗口。

Even if I select only one message in the conversation (eg, the top most message), the script still opens up 4 separate reply windows. 即使我在对话中仅选择一条消息(例如,最上面的消息),该脚本仍会打开4个单独的回复窗口。

I also tried the following, but nothing happens: 我也尝试了以下方法,但是没有任何反应:

tell application "Mail"

    set theSelection to item 1 of selection
    if theSelection is {} then return
    activate

    set theOutgoingMessage to reply theSelection with opening window

end tell

But this has no visible result (no window opens at all). 但这没有可见的结果(根本没有打开任何窗口)。 Any help to point me in the right direction? 有什么帮助我指出正确的方向吗?

.R .R

The following code eventually worked for me: 以下代码最终为我工作:

tell application "Mail"
    set theMessages to the selected messages of the front message viewer
    set theMessage to first item of theMessages
    set theOutgoingMessage to reply theMessage with opening window and reply to all
end tell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM