Before you start
If you haven't already, be sure to complete all steps in the Prerequisites to enable EchoMark for Microsoft Exchange.
By default, using the Connectors we set up in the prerequisites guide, nothing will be EchoMarked. The rule created in this guide will initiate marking for messages and attached PDFs meeting the rule criteria.
Create a mail flow rule
The mail flow rule will determine which messages get EchoMarked.
- Within the admin portal, navigate to Mail flow > Rules
- Press Add a rule and then Create new rule from the dropdown.
-
In the Set rule conditions page, you'll want to specify the conditions that messages must meet in order to get routed through EchoMark. Set the fields as follows:
Name EchoMark outbound Apply this rule if The sender is this person [use your own email address] And The subject or body subject or body includes any of these words #echomark Do the following Redirect the message to the following connector EchoMark Outbound Connector Except if The message headers... includes any of these words 'x-personalized-for' message header includes 'recipient' Or The message properties include the message type 'Calendaring' Or The message headers... matches these text patterns 'Auto-Submitted' message header matches 'auto-generated'
-
IMPORTANT! On the next page, check the box titled Stop processing more rules, and select Envelope in the Match sender address in message dropdown.
- Press Next and then Finish to complete the creation of this rule.
- Once the rule has finished saving, select the rule you just created from the Rules list, and from the panel that opens, enable your new rule by pressing Enable or disable rule.
The following script creates the mail flow (transport) rule via the Exchange Online PowerShell module. You must have the ExchangeOnlineManagement module installed and be signed in as an Exchange Admin.
1. Set up powershell module and authenticate
# Install if not present, and import
Install-Module ExchangeOnlineManagement -Scope CurrentUser -Force
Import-Module ExchangeOnlineManagement
# Authenticate to Exchange Online
Connect-ExchangeOnline `
-UserPrincipalName "admin@mydomain.com" `
-ShowBanner:$false
2. Run the script
#
# Set variables
#
# When email is from this user and the subject contains this keyword, the email
# will get routed to EchoMark
$optinUser = "user@mydomain.com"
$optinSubjectKeyWord = "#echomark"
# Rule name shown in the Exchange Admin center
$transportRuleName = "EchoMark outbound opt-in rule"
# Must match the name of the outbound connector
$outboundConnectorName = "Outbound to EchoMark"
New-TransportRule -Name $transportRuleName `
-Priority 0 `
-From $optinUser `
-SenderAddressLocation Envelope `
-SubjectContainsWords $optinSubjectKeyWord `
-FromScope InOrganization `
-RouteMessageOutboundConnector $outboundConnectorName `
-StopRuleProcessing $true `
-ExceptIfHeaderContainsMessageHeader 'x-personalized-for' `
-ExceptIfHeaderContainsWords 'recipient' `
-ExceptIfHeaderMatchesMessageHeader 'Auto-Submitted' `
-ExceptIfHeaderMatchesPatterns 'auto-generated' `
-ExceptIfMessageTypeMatches 'Calendaring'
Note: The -SenderAddressLocation Envelope parameter is the PowerShell equivalent of the Web UI's "Match sender address in message: Envelope" setting. Without this, the rule will evaluate the From header rather than the envelope sender, which can lead to messages being incorrectly marked or skipped.
Note: New transport rules are created in a disabled state by default. To enable the rule, run:
Enable-TransportRule -Identity $transportRuleName
Try it out
EchoMark is now active for the sender you specified. You can EchoMark messages by sending them from the email address you set as the sender and including #echomark in the subject or body of the message.