To create a rule with wildcards

Last reviewed on March 25, 2014   —  20 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:


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
  End If
End Sub

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

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

20 responses to “To create a rule with wildcards”

  1. Chris


    is it possible to create a rule to manage spam from info domain. For example;

  2. Bryan

    Is it possible to create a rule using numbers (e.g.fax numbers) instead of names?

  3. Rommel Sharma

    Thank you for the useful post.

  4. Ed Lane

    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?

    1. Lewis

      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.

  5. Ed Lane

    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.

  6. Per Lindgren

    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 "". I asked for an "alias" to that address "" 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 "" 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", "". 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 "" address.
    Phew... Any suggestions?!?
    Kind regards

  7. MCP Trainer

    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")?

  8. Kelly Napier

    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?

  9. Stanley

    how does syntax's work in rules? Do they express unique meanings

Leave a Reply

If the Post Coment button disappears, press your Tab key.