Send & Receive Issues

Prevent Exchange Online From Removing a Custom Email Header

Tauseeq MagsiTauseeq Magsi Nov 14, 2026 868 views

Question details

Determine why a custom email header is missing or changed and whether an Exchange Online mail flow rule can add the required header.

Prevent Exchange Online From Removing a Custom Email Header
Product
Microsoft 365 Exchange Online
Device & OS
not provided
Scenario
An application sends messages with a custom header containing XML or application-specific data through Exchange Online.
Observed behavior
The custom header or its contents may be changed or missing in the received message.
Before you start

Have a controlled test message, the expected header name and value, and access to its complete headers before and after delivery. To create a rule, you also need an Exchange Online role with permission to manage mail flow rules.

Solution 1Recommended

Add the Required Header With an Exchange Online Mail Flow Rule

Use this approach when a known header value can be added to matching messages during Exchange Online transport.

A mail flow rule can set a specified header value, but it does not guarantee preservation of every third-party header. In particular, setting a fixed value cannot recover a dynamic value that was already removed.

1
Compare the message headers

Open the complete headers for the test message before and after delivery. Compare the custom header name and value to identify where they differ; include any intermediate gateway logs or headers available.

2
Create a mail flow rule

In the Exchange admin center, go to Mail flow > Rules, select Add a rule, and choose Create a new rule.

3
Set the header

Name the rule and select conditions that limit it to your test messages, such as the sender. Under Do the following, choose Modify the message properties > Set a message header, then enter the required header name and a suitable fixed value.

4
Save and test the rule

Complete the rule settings, save and enable the rule, then send a controlled test message. Open the delivered message's complete headers and check whether the expected header and value are present.

Add the Required Header With an Exchange Online Mail Flow Rule
Check downstream processing: Another gateway or recipient system may still modify or remove the header after the rule runs. Header values must also meet applicable email formatting and size requirements.
Free Microsoft Office alternative

Work With Office Files in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making it easier to move everyday document work. It does not change Exchange Online mail flow or fix email header removal.

Create and edit documents you may need to send by emailCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for everyday Office tasksFree and lightweight alternative for working with existing files
microsoft office alternative - wps office

Frequently Asked Questions

Can a mail flow rule preserve the original value of every custom header?

No. A rule can set a specified header value on matching messages, but it cannot necessarily recover a dynamic value that was removed before the rule ran. Test the complete delivery path.

Where do I create an Exchange Online header rule?

In the Exchange admin center, go to Mail flow > Rules > Add a rule > Create a new rule. Under Do the following, select Modify the message properties > Set a message header.

Why is the header still missing after I add a rule?

The rule may not match the test message, may not be enabled, or a later gateway or recipient system may remove the header. Check the rule conditions and compare headers and logs at available points along the delivery path.

Can I put XML directly in a custom email header?

Header values must comply with email header formatting and size requirements, and transport systems may modify or reject unsuitable values. Consider sending complex XML in the message body or an attachment instead.