0

Is it possible to use apple script in mail to sort newsletter by updating a rule when I put a email for training in a specific mail folder?

  1. in mail is a folder named "trainNewsletter"
  2. in mail / rules is a rule "Newsletter" witch move mails into the folder "Newsletter" with
  3. specific from-mail-address
  4. if there is a mail in the inbox witch from-mail-address is not in the rule "Newsletter" the mail stays in the inbox
  5. I move the mail to the folder "trainNewsletter" an the script add the from-mail-address to the rule
  6. next time I get an mail with this from-mail-address it moves direkt to the folder "Newsletter"
Kara
  • 6,115
  • 16
  • 50
  • 57
andy19
  • 3
  • 5
  • "Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results." [What have you tried?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – adayzdone Dec 05 '14 at 14:24

1 Answers1

0

I'm not sure if moving the mail to another folder will trigger the rule appended to this folder, but maybe you can trigger this rule manually if needed:

Save this as a new mail rule and connect it to your folder trainNewsletter, it should get the email's sender and add it as a from is equal to-rule condition to your rule Newsletter:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with thisMessage in theMessages
                -- getting the sender of the email
                set theSender to sender of thisMessage

                -- setting the sender as a rule condition of rule "Newsletter"
                tell rule "Newsletter"
                    make new rule condition with properties {header:"", expression:theSender, rule type:from header, qualifier:equal to value}
                end tell

            end repeat
        end tell
    end perform mail action with messages
end using terms from

Enjoy, Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18