-1

我使用 google 帐户,例如 myaccount@google.com 用于工作,我为我正在从事的各种项目使用别名。因此,对于 project1,我使用 myaccount+projet1@google.com,对于 project2,我使用 myaccount+projet2@google.com 等等。我不需要在 Mail 中添加其他帐户,因为 GMail 会忽略“+”号之后的内容。现在,在我的邮件帐户的配置中,我将所有地址(包括带有别名的地址)放在“电子邮件地址”字段中,用逗号分隔。因此,我可以从我的任何电子邮件 myaccount+project*@google.com 发送消息。

我的问题是关于“回复”标题,我必须手动选择它才能在正确的文件夹中接收邮件。我查看了设置,找不到解决方案。您是否知道自动执行此操作的任何方法(将回复标头设置为与发件人相同)?也许是苹果脚本?我知道我可以使用“默认写入”命令,但只允许为所有电子邮件指定一个特定的“回复”标题,这不是我想要的。

先感谢您。

4

1 回答 1

1

这是我的 WIP,我现在发布它,以防我永远不会完成它。希望我会用一个读取必填字段而不是硬编码的示例来更新它。

(第三次也可能是最后一次更新)

抱歉,如果这不能完全满足您的需求,但它确实满足了我的需求,并且我相信您的要求比我的要简单。

-- Reply to current message with additional header changes.
-- (To be triggered from Keyboard Maestro, or ControllerMate on Alt-R)

-- function to read/focus/change data in message field
-- usage: set fieldValue to message_field("reply_to", false) 
--        message_field("reply to", "moron")
on message_field(fieldname, newValue)
    local tElements, tElement, tField, tValue, tClass
    tell application "System Events"
        tell process "Mail"
            set frontmost to true
            set tElements to scroll areas of window 1
            repeat with tElement in tElements
                set tName to get name of tElement as string
                try
                    set tField to text field 1 of tElement
                    ignoring white space and punctuation

                        if (name of tField as string = fieldname) then
                            try
                                set tValue to get value of tField as string
                            on error
                                set tValue to ""
                            end try

                            set focused of tField to true

                            if (newValue ≠ false) then
                                set value of tField to newValue -- as string

                            end if
                            exit repeat
                        end if
                    end ignoring
                end try
            end repeat
        end tell
    end tell
    return tValue
end message_field

-- split function (julifos @ macscripter.net)
to split(someText, delimiter)
    set AppleScript's text item delimiters to delimiter
    set someText to someText's text items
    set AppleScript's text item delimiters to {""} --> restore delimiters to default value
    return someText
end split

-- Get information from current/selected message
tell application "Mail"
    set theSignatureName to "Signature #1"
    set theMessages to the selected messages of the front message viewer
    set theMessage to first item of theMessages

    -- Get the email address (ours, hopefully) the message was sent to
    set theMessageWasTo to address of first to recipient of theMessage as string


    -- Unfortunately, it seesm that Mail doesn't honour the existing Reply-To header
    -- when a reply is triggered from a script, instead of from the Reply menu.
    -- So here is a bit of a dance to get it.
    set theMessageHeaders to headers of theMessage
    try
        set theMessageReplyToWas to first item of {reply to} of theMessage -- (thx to Brian Christmas)
        tell me to set theMessageReplyToWas to item 1 of split(theMessageReplyToWas, ",")
    on error
        set theMessageReplyToWas to sender of theMessage
    end try

    -- you can also use: set temp to {deleted status, all headers, was replied to, flag index, date received, message id, background color, subject, read status, flagged status, message size, date sent, junk mail status, source, sender, was forwarded, was redirected, content} of foo 



    -- set Theheaders to all headers of theMessage -- If you want to get all the headers in text form and process manually
    -- set mySource to source of theMessage -- If you want the message source

    set theOutgoingMessage to reply theMessage with opening window

    -- I want to set "Reply-To" to be the address the message was sent to
    tell me to message_field("reply to", theMessageWasTo)

    tell theOutgoingMessage
        -- I don't like this, as it adds an extra recipient
        make new to recipient with properties {address:theMessageWasTo}
        -- so I'll do it my way
        tell me to message_field("to", theMessageWasTo)
    end tell

    -- It's easier if you just want to change the sender or signature or something
    -- set message signature of theOutgoingMessage to signature theSignatureName
    -- set sender of theOutgoingMessage to "Federico Viticci "

end tell

-- Now all that remains is to set the focus back to the body of the message.
于 2013-11-15T11:11:36.130 回答