Last reviewed on March 25, 2014   —  22 comments

Outlook doesn’t support wildcards in rules, so you can’t use use a * or ? character for wildcards. Instead, just specify the string you want to match. For example, if you want to match anything with “foo” in the subject text, then any the following would cause the rule to fire:

Foobar
Fools
tofoo

Note that the Rules Wizard supports wildcarding for e-mail addresses. By using the “with specific words in the recipient’s address” and “with specific words in the sender’s address” conditions, you can set rules for everyone from a particular domain, for example. See Creating Rules that Apply to an Entire Domain for more information.

However, these address rules do not work for Exchange Server recipients since the Exchange server addresses do not show up in the message header. To apply a rule to addresses within your Exchange organization (or exclude them), use @ as the word in the address (or exclude messages with @ in the address). See Creating a Rule to Filter Blank Senders for more information.

Display names

While a partial word filter won’t work in all circumstances, you can use it to filter the display name of senders. For example, this rule will filter messages from Forum Administrator

rule test

Tip: Cancel the Check names dialog when adding the name to the people or group field:

Create a rule to filter partial display names

Run a Script rule

When a rule that looks for partial words isn’t working, you can use a run a script rule. This example shows how to filter for the Sender’s display name, but it can be used with any Outlook email field.

Sub CheckSpam(Item As Outlook.MailItem)
  If InStr(LCase(Item.SenderName), "pfizer") Then
    Item.Delete
  End If
End Sub

See Outlook’s Rules and Alerts: Run a Script for more information on using a run a script rule.

Comments

  1. Ed Lane says

    My spam comes mostly from variations of the word "Pfizer" in the From field in Outlook. ActivePfizer, SafePfizer, etc., however they don't all come from the same email address nor domain.

    How can I create a rule that filters out any wildcard variations of Pfizer in the From Field. Suggestions?

    • Diane Poremsky says

      Rules don't support wildcards but if you can use VBA, a script in a run a script rule will. I'll put something together.

      BTW, just entering 'pfizer' in a rule for messages from sender might also work, however checking senders names can be hit or miss.

    • Diane Poremsky says

      Try this - it will look for pfizer in the sender's display name and match any case.

      Sub CheckSpam(Item As Outlook.MailItem)
      If InStr(LCase(Item.SenderName), "pfizer") Then
      Item.Delete
      End If
      End Sub

    • Lewis says

      If you are using an Exchange server, why not use Exchange SCL? Otherwise, you're better off buying an antispam software (which ideally sits at your email server level), in my opinion.

      That way, you have less chance of vulnerabilities being exploited.

    • Diane Poremsky says

      Only an admin can configure the SCL settings on exchange. For client side use, 3rd party antispam software is often more trouble than its worth. It's really better to enable filtering on the mailbox at the server level.

  2. Ed Lane says

    Hi Diane. Thanks so much for your time and responses.

    I tried the sender "Pfizer" option, but unless the sender name is exactly "Pfizer", it won't work (ie, "ExtremePrizer" is not deleted.

    Sorry to say but, unless I'm doing something wrong, the script isn't working. I saved your text as PfizerScript.vbs and if I execute as an object in Explorer, or open command line and execute using CScript, it fails.

    Error is in line 1, Character 20. Error is: Expected ')', Code 800A03EE

    Sorry and thank you again for the help.

  3. Per Lindgren says

    Hi!
    I'm a beginner with Outlook (and Windows), so this might be a simple question. I have an email address in my companys Exchange server, say "myname@company.com". I asked for an "alias" to that address "myname2@company.com" and my idea was to use that alias when subscirbing to mailing lists, requesting whitepapers etc etc.Then I could differentiate a little between more serious mail (to "myname") and possibly less seriouse mail (to "myname2"). Now I want to create a rule that puts all mail to "myname2@company.com" in a separate folder. I've tried to use the rule wizard to create a rule that triggers on "myname2" as a word in the recipient address (I'm not sure of the exact terminlogy since my Outlook is in Swedish!). My rule doesn't trigger. Regardless of the words in the rule. I've tried "myname2", "myname2@company.com". without luck. If I try to trigger on "myname" (without the "2") - i.e. my original address - the rule works. To me it looks like the rule doesn't see the alias address at all, just the adress that the alias is pointing to. If I look at the mail headers of a message to "myname2" to To-field looks correct with the "myname2@company.com" address.
    Phew... Any suggestions?!?
    Kind regards
    Per

    • Diane Poremsky says

      Use the words in the header rule instead. The recipient address one seems buggy. Hopefully, all of the things you subscribed to use the address in the to fled instead if BCC'ing it.

    • Per Lindgren says

      Great! Worked like a charm. In swedish that option is (very badly translated) "med specifika ord i meddelanderubriken", in case other swedes finds this Q and A!
      Thanks! :-)

  4. MCP Trainer says

    Is it possible to make a rule using AND clause in a subject line (subject with "xxx" AND "yyy", for example, rather than "xxx" OR "yyy")?

    • Diane Poremsky says

      With rules, no.

      Filters (views, search folders, advanced find), yes. In a filter you'd use subject field only xxx yyy - this will find words containing xxx or yyy - for example, filtering for us returns business, us, plus...

  5. Kelly Napier says

    I have a checklist form that employees fill out. The email generated by this form has "Checklist Comments :" in the header, followed by any comments they may have entered. The "Checklist Comments :" is persistent whether they entered comments or not. Is there a way to set up a rule to look for specific text followed by any character so that I can see only the emails with actual comments or is that the exact type of "wildcard" this thread is referring to?

    • Diane Poremsky says

      That would require a wildcard. You could do it using a run a script rule. if you can count on a character or phrase being present, you could use an exception. 'if checklist then move, except if #' type rule.

    • Diane Poremsky says

      I'm not sure what you mean - Outlook's rules are pretty basic, nothing unique or hidden features.

Leave a Reply