AppleScript 将所选邮件中的多个地址添加到给定规则

AppleScript to add multiple address from selected message to given rule

想要Select多条消息在Mail.app,那么 1.move 他们到文件夹“AdvertRule” 2.Add 现有规则“TestRule 23”的条件(发件人的电子邮件地址)

代码的结果

  1. 完美运行
  2. 部分,wud 向规则添加条件,如果选择了 x 条消息,则为 x 次,并且所有电子邮件地址的条件与 ( a@aa.com b@bb.com c@cc.com)

想知道是否可以帮助为规则中的每个条件获取 1 个电子邮件地址

如果有纠错就更好了(如果已经存在就不会形成新的条件)

提前Tx

(*
Based on
https://apple.stackexchange.com/questions/149008/in-mail-app-get-list-of-recipients-for-just-one-of-the-many-email-accounts
https://discussions.apple.com/thread/7319379
Move selected Messages to another Folder
*)
tell application "Mail"
    set theSenderList to {}
    set target_account to "Exchange"
    set target_mailbox to "AdvertRule"
    set theMessages to the selected messages of message viewer 0
    repeat with aMessage in theMessages
        set end of theSenderList to (extract address from sender of aMessage)
        set oldDelimits to AppleScript's text item delimiters
        set AppleScript's text item delimiters to "     "
        set theSender to (theSenderList as string)
        set AppleScript's text item delimiters to oldDelimits
    end repeat
    set r to rule "TestRule 23"
    set s to selection
    if s is not "" then
        repeat with currentMessage in s
            move currentMessage to (first mailbox whose name is target_mailbox) of account target_account
            tell r
                make new rule condition at end of rule conditions with properties {expression:theSender, qualifier:does contain value, rule type:from header}
            end tell
        end repeat
    end if
end tell

嘿,看完了初学者的 applescript 获取发件人列表后,然后为发件人列表中的每个发件人添加规则,然后选择每条消息,移动消息

真有用