2

I can't seem to find a simple way to filter mail that is either to or from a given address. It seems that you have to duplicate the address and use two conditions e.g.

From - contains - fred@nowehere.com
Any recipient - contains - fred@nowehere.com

I would have hoped that "Any recipient" might include "From" but it seems that it only includes "To", "Cc", "Bcc", etc.

2
  • 1
    Am I missing something? Can't you just set up a rule with those exact two conditions and select any in the popup: "If any of the following conditions are met:" What's wrong with using two conditions?
    – ghoppe
    May 12, 2011 at 18:30
  • The problem is that I have a lot of filters and some of them have several email addresses so I would have to go through all these duplicating every From: test and making it an Any recipient: test - a maintenance headache as well as all the initial pain. I miss Eudora sometimes...
    – Paul R
    May 12, 2011 at 20:06

2 Answers 2

2

Rules are unfortunately quite limited, but you can sometimes use Smart Mailboxes to help you work around the problem.

For example, if you need a Rule that performs an action when the conditions (A OR B) AND C are met, you can set up a Smart Mailbox called 'X' that contains all emails where (A OR B) is true, then a second Smart Mailbox called Y that contains all emails where (C is true AND Mailbox Is X).

If necessary, you could then set up a rule that does whatever processing you need to do on the contents of mailbox Y, and run it manually as required (select all messages in mailbox Y, then Message->Apply Rules).

1
  • Thanks for that suggestion - a neat bit of lateral thinking - I'm not sure that it helps for my particular problem but I can see that it could be a useful trick in other cases.
    – Paul R
    May 31, 2011 at 21:15
2

This question showed up on my radar again because my comment was voted up, but there are still no good answers so I'll go the extra mile. ;) It's an interesting exercise.

You say that you "have a lot of filters and some of them have several email addresses so I would have to go through all these duplicating every From: test and making it an Any recipient: test - a maintenance headache as well as all the initial pain"

This maintenance headache could be removed through the magic of Applescript. The following script takes messages selected in Apple Mail, goes through all the "sender" fields to find new senders that don't already have one of these "from/any recipient" rules, and if not creates a new rule with your "from/any recipient" rule conditions.

I'm not sure exactly what you're doing with the Mail Rules, but I'll presume you're setting up folders for each Mail "conversation" with each email address. I only search the "from" header to set up these as an email might have many recipients. It's rough and ready, and you'll want to modify it yourself. For example, I don't do any sanity checking of Mailbox names, a name with a forward slash will cause extra mailboxes to be made.

Here it is!

tell application "Mail"
    set _sel to get selected messages of first message viewer
    repeat with _msg in _sel
        set _senderEmail to extract address from sender of _msg
        set _ruleName to "Conversations with <" & _senderEmail & ">"
        set _mailRules to rules
        set foundIt to false
        repeat with _rule in _mailRules
            if ((extract address from name of _rule) is _senderEmail) then
                set foundIt to true
                exit repeat
            end if
        end repeat
        if not foundIt then
            set _senderName to "Conversations/" & (extract name from sender of _msg)
            if not (mailbox _senderName exists) then
                make new mailbox at end of mailboxes with properties {name:_senderName}
            end if
            set _destination to (mailbox _senderName)
            set newRule to make new rule at end of rules with properties {name:_ruleName, enabled:true, should move message:true, all conditions must be met:false}
            tell newRule
                make new rule condition at end of rule conditions with properties {rule type:from header, expression:_senderEmail, qualifier:does contain value}
                make new rule condition at end of rule conditions with properties {rule type:any recipient, expression:_senderEmail, qualifier:does contain value}
                set move message to _destination
            end tell
        end if
    end repeat
end tell
1
  • Thanks very much for that - I may well be able to adapt your script to my needs.
    – Paul R
    Aug 30, 2011 at 6:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .