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

Email AppleScript将所选邮件中的多个地址添加到给定规则,email,applescript,action-mailbox,Email,Applescript,Action Mailbox,要在Mail.app中选择多封邮件,请 1.将其移动到“广告规则”文件夹中 2.将条件(发件人的电子邮件地址)添加到现有规则“TestRule 23” 来自代码的结果 完美地工作 部分,wud将条件添加到规则中,如果选择了x条消息,则为x次,并且所有电子邮件地址与(a@aa.com b@bb.com c@cc.com) 想知道是否可以为规则中的每个条件获取1个电子邮件地址 如果有错误更正,则更好(如果wud已经存在,则不会形成新条件) 提前发送 (* Based on https://apple

要在Mail.app中选择多封邮件,请 1.将其移动到“广告规则”文件夹中 2.将条件(发件人的电子邮件地址)添加到现有规则“TestRule 23”

来自代码的结果

  • 完美地工作
  • 部分,wud将条件添加到规则中,如果选择了x条消息,则为x次,并且所有电子邮件地址与(a@aa.com b@bb.com c@cc.com)
  • 想知道是否可以为规则中的每个条件获取1个电子邮件地址

    如果有错误更正,则更好(如果wud已经存在,则不会形成新条件)

    提前发送

    (*
    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
    
    

    嘿,在阅读了初级应用程序脚本之后 获取发件人列表后,在发件人列表中的每个发件人中添加规则,然后在选择中的每个邮件中移动邮件

    那玩意儿真管用