How to Encrypt Exchange Online Email When Subject Starts with a Tag
Question details
The user needs to set up a mail flow rule that applies encryption to an email only if its subject line starts with a specific tag, avoiding false positives.

- Product
- Exchange Online
- Device & OS
- not provided
- Scenario
- Configuring automated Office 365 Message Encryption based on specific subject line formatting.
- Observed behavior
- Standard 'subject includes' rules match the tag even if it appears in the middle of the subject line, which triggers encryption incorrectly.
Ensure you have Exchange Administrator permissions in your Microsoft 365 tenant to access and modify mail flow rules in the Exchange Admin Center.
Configure Mail Flow Rule with a Regular Expression
Use a regular expression in your mail flow rule to ensure the tag is only matched at the very beginning of the subject line.
The Exchange Admin Center allows you to use regular expressions for precise string matching. By using the caret character (^), you can specify that the tag must appear exactly at the start of the subject line to trigger the encryption.
Log in to the Microsoft 365 Exchange admin center using your administrator credentials.
Go to 'Mail flow' in the left-hand menu and select 'Rules'.
Click 'Add a rule' and choose 'Apply Office 365 Message Encryption and rights protection to messages' from the template list.
In the 'Apply this rule if' section, select 'The subject or body matches these text patterns'.
Enter a regular expression like ^[zip] to strictly match subjects starting with your tag, then save the rule.

Use the 'Subject starts with' Condition
If your Exchange Admin Center interface provides it, use the direct 'starts with' condition for a simpler setup without regular expressions.
Try WPS Office for Seamless Document Management
While Exchange Online handles your server routing and email encryption, WPS Office provides a lightweight, highly compatible desktop suite for opening, editing, and protecting the actual documents you attach to those secured emails.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package.
- 2. Install the Software: Run the installer and follow the quick on-screen setup instructions.
- 3. Open and Protect Documents: Open your files, edit them seamlessly, and apply document-level passwords before emailing.

Frequently Asked Questions
Why does my encryption rule trigger when the tag is in the middle of the subject?
This happens if the rule uses a 'subject includes' condition, which scans for the specified text string anywhere in the subject line. To fix this, you must use a regular expression starting with a caret symbol (^) or a strict 'starts with' condition to enforce matching only at the beginning.
Can I also trigger Exchange email encryption based on tags in the email body?
Yes, Exchange mail flow rules allow you to set conditions based on 'The subject or body includes any of these words.' This will trigger the designated encryption if the tag is found in either the subject line or the body text of the message.
Does applying Office 365 Message Encryption require a specific license?
Yes, utilizing Office 365 Message Encryption (OME) requires a Microsoft 365 subscription that includes Azure Information Protection Plan 1 or Microsoft 365 Business Premium, E3, or E5 licenses.




