Create an Exchange Mail Rule for Specific Subject Patterns
Question details
The user needs to create an email rule that matches subjects beginning exactly with 'SOP' and also containing the phrase 'Document Ready'.

- Product
- Microsoft Exchange Online
- Device & OS
- not provided
- Scenario
- Automating the routing or management of specific standard operating procedure (SOP) notification emails.
- Observed behavior
- Standard Outlook client rules lack the functionality to combine a 'begins with' condition and a 'contains' condition for the same subject line.
Ensure you have administrative access to the Exchange Admin Center or PowerShell, as advanced regular expression pattern matching requires tenant-level mail flow rules.
Use Exchange Admin Center with Regular Expressions
Exchange mail flow rules (transport rules) support regular expressions, allowing you to create complex subject matching criteria.
Since standard client-side Outlook rules only support basic 'contains' matching, using a regular expression (Regex) in the Exchange backend is necessary to strictly enforce that a subject starts with a specific word.
Log in to the Microsoft 365 admin center using your administrator credentials, navigate to the Admin centers menu, and select Exchange.
Go to 'Mail flow' > 'Rules'. Click the '+' icon and select 'Create a new rule'. Give your rule a descriptive name and click 'More options' at the bottom of the window to reveal advanced settings.
Under 'Apply this rule if...', select 'The subject or body' from the first dropdown, and then choose 'subject matches these text patterns' from the second dropdown.
Enter the regular expression ^SOP.*Document Ready into the text box and add it. This ensures the subject strictly starts with 'SOP' and contains 'Document Ready' later in the text.
Under 'Do the following...', select the desired action, such as redirecting the message to a specific mailbox or applying a disclaimer, then save the rule.

Deploy the Rule via Exchange Online PowerShell
For advanced administrators, PowerShell offers a quick method to deploy regex-based transport rules across the organization.
Draft and Manage Your SOP Documents Efficiently with WPS Office
While advanced email routing requires Microsoft Exchange, creating, editing, and managing your Standard Operating Procedure (SOP) documents is seamless with WPS Office. Experience a lightweight, powerful suite tailored for your everyday document tasks.

Frequently Asked Questions
Can I create a 'begins with' subject rule in the standard Outlook desktop app?
No, standard Outlook client rules primarily use 'contains' logic for subjects. To strictly enforce a 'begins with' condition, you typically need to use Exchange transport rules configured with regular expressions.
What regular expression matches a subject starting with specific text?
Use the caret symbol (^) followed by your target text. For example, using '^SOP' ensures the rule only triggers if 'SOP' appears at the absolute beginning of the subject line.
Do Exchange mail flow rules apply to all users?
Yes, mail flow (transport) rules configured in the Exchange Admin Center operate at the server level, affecting messages for all mailboxes in the tenant unless you configure specific user exceptions within the rule.
Why is my regex mail flow rule not working?
Ensure you have selected the 'matches these text patterns' condition rather than 'includes any of these words' in the rule settings, as regular expressions are only interpreted correctly when the pattern matching option is used.




