想要在 Mail.app 中选择多条消息,然后 1.将它们移动到文件夹“AdvertRule” 2.将条件(发件人的电子邮件地址)添加到现有规则“TestRule 23”
代码结果
- 完美运行
- 部分,向规则添加条件,如果选择了 x 条消息,则为 x 次,并且所有电子邮件地址的条件与 (a@aa.com b@bb.com c@cc.com) 中的条件相同
想知道是否可以帮助为规则中的每个条件获取 1 个电子邮件地址
如果有纠错就更好了(如果它已经存在则不会形成新的条件)
提前发送
(*
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