Data Protection Issues

Apply Microsoft 365 Do Not Forward Protection Programmatically

Huma Ashraf ChHuma Ashraf Ch Nov 22, 2026 868 views

Question details

Apply Do Not Forward protection to an Exchange Online email generated or processed programmatically.

Apply Microsoft 365 Do Not Forward Protection Programmatically
Product
Microsoft 365 Message Encryption and Exchange Online
Device & OS
not provided
Scenario
A developer wants to protect an email with Do Not Forward, potentially using C# or Exchange Web Services.
Observed behavior
Protect-RMSFile can protect a local file, but the resulting PFILE cannot be uploaded to Exchange Online as a Do Not Forward-protected email.
Before you start

Confirm that your Microsoft 365 subscription supports Message Encryption and that it is configured for your Exchange Online organization. You also need permission to create mail flow rules in the Exchange admin center.

Solution 1Recommended

Apply Do Not Forward with an Exchange Online mail flow rule

Use a mail flow rule to protect messages that match conditions you define, including messages sent by an application.

Do Not Forward is a message-level restriction in Microsoft 365 Message Encryption. Protect-RMSFile applies rights protection to files and does not convert an MSG or PFILE into an Exchange Online message with the same restriction.

1
Open mail flow rules

Sign in to the Exchange admin center, then go to Mail flow > Rules and choose Add a rule.

2
Set the matching conditions

Create a rule with conditions that identify the messages to protect, such as the application's sender address and a specific subject phrase. Keep the conditions narrow enough to avoid affecting unrelated mail.

3
Select Do Not Forward

Under the rule actions, choose Modify the message security > Apply Office 365 Message Encryption and rights protection, then select Do Not Forward.

4
Save and test the rule

Save and enable the rule, then send a matching test message from the application to a test recipient. Open the message in a supported mail client or the encryption portal and verify that forwarding is restricted.

Apply Do Not Forward with an Exchange Online mail flow rule
For custom API development: A mail flow rule applies protection after a message matches the rule; it is not a direct C# or Exchange Web Services call to apply Do Not Forward. For an API-specific implementation, consult current Microsoft developer documentation or ask on Microsoft Q&A with the API and authentication method you use.
Free Microsoft Office alternative

Work with Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with Office documents. Its format compatibility makes it easier to move existing files into WPS, but it does not apply or replace Exchange Online Do Not Forward protection.

Open and edit Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTX.Prepare documents for sharing alongside your existing Exchange Online email workflow.Use a familiar interface to make moving from Microsoft Office easier.Work with a free, lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why can't I use Protect-RMSFile to apply Do Not Forward to an email?

Protect-RMSFile protects files, while Do Not Forward is applied to an Exchange Online message through Microsoft 365 Message Encryption. Protecting a local MSG file does not apply the message-level restriction to an email.

Can a mail flow rule protect email sent by an application?

Yes. In the Exchange admin center, go to Mail flow > Rules and create a rule that matches the application's messages. Set the message security action to apply encryption and rights protection with Do Not Forward.

What does Do Not Forward prevent recipients from doing?

Do Not Forward restricts actions such as forwarding and changing recipients. Other restrictions, including printing or saving, depend on the client and how the protected content is accessed; it cannot prevent someone from capturing the content by other means.

Where can I get help applying protection through C# or an Exchange API?

Consult the current Microsoft developer documentation for your chosen API, or post on Microsoft Q&A with details of your C# application, API, and authentication method. Do not assume that a file-protection API applies message-level restrictions.