Cover Image for Exchange transport agent: architecture, limits and risks

Exchange transport agent: architecture, limits and risks

What a transport agent can do in Exchange Server, how it differs from transport rules and where agents fail in production: critical flag, TNEF, outages and updates.

4 minExchange

Transport rules cover a lot: append a notice, send a copy, set a header. Where they stop, the transport agent begins. It is the oldest and most powerful extension point in Exchange, and the one with the most traps.

What a transport agent is

A transport agent is a .NET library loaded by the Exchange transport service. It hooks into events while a message is processed and gets access to envelope, headers and content. The reference libraries for compiling sit on the server in the Public folder of the Exchange installation.

Two types matter in practice:

  • SmtpReceiveAgent works during SMTP receive, for example at OnEndOfData. It only sees what arrives over SMTP.
  • RoutingAgent works in categorization with OnSubmittedMessage, OnResolvedMessage, OnRoutedMessage and OnCategorizedMessage. It sees every message, including those Outlook submits directly that never travel over SMTP.

For internal mail, only a RoutingAgent will do.

Transport rule or agent

QuestionTransport ruleTransport agent
SetupExchange admin center or PowerShellInstallation on every transport server
Capabilitiesfixed conditions and actionsanything the API allows
Route through a specific connectorExchange Online onlyyes
Upkeep on updatesnonecheck per CU
Risk to mail flowlowhigh on errors

Installation

Install-TransportAgent -Name "My Agent" -TransportAgentFactory "Company.Agent.Factory" -AssemblyPath "C:\Agent\Company.Agent.dll"
Enable-TransportAgent -Identity "My Agent"
Set-TransportAgent -Identity "My Agent" -Priority 10
Restart-Service MSExchangeTransport

Get-TransportAgent shows order and state. Priority decides which agent sees a message first. Two agents rewriting the same message only get along with a clear order.

Where agents fail in production

The critical flag

Exchange registers a newly installed agent as critical in agents.config. If a critical agent fails to load at startup, for instance because a dependency is missing, the whole transport service does not start. Then mail flow stops, not just the agent. Check that flag after every installation.

The Outlook format

Outlook sends within the organisation in its own TNEF format, ordinary messages included. If an agent reads the content as MIME, Exchange creates a conversion with winmail.dat. For meetings the conversion back fails with Corrupt summary TNEF content, and the sender gets a non-delivery report. An agent has to distinguish by message class: leave meetings and tasks untouched, convert ordinary messages cleanly.

If you only test with scripts or Outlook on the web, you never notice. Both send MIME.

Downstream outages

When an agent hands messages to another system, it has to handle that system being down. A RoutingAgent can defer a message with Defer, and Exchange retries later. Letting it through instead delivers exactly what the agent was supposed to prevent.

Updates

Every cumulative update is a test for the agent. The first release of Exchange SE is code-equivalent to Exchange 2019 CU15, later updates may differ. A maintained agent has a vendor who checks every new CU.

Checklist for third-party agents

  1. Does the vendor support your Exchange version in writing?
  2. Is the agent registered as critical, and is that intended?
  3. What happens when the target system is unavailable?
  4. How does the agent handle meetings and messages in Outlook format?
  5. How is it updated, and is the configuration kept?

The Conbool Exchange agent

Conbool uses a RoutingAgent to route internal mail through the gateway. It removes the critical flag after installation, defers when the gateway is unavailable, distinguishes Outlook messages by class and starts in observe mode. Background in why internal email in Exchange never reaches a gateway, setup in the Exchange agent documentation and the overview on encrypt internal email in Exchange.

Set Conbool as a preferred source on Google

Google shows content from preferred sources more often in Search, in AI Overviews and in AI Mode. The selection can be changed at any time.

Set as preferred source

More articles

The latest posts from our blog.