Lately I've been working on few Transport Agents which I feel maybe handy to share.
While the logic adopted is very simple, the sample showcase how to inspect and modify entries in the P1 and P2 headers.
The requirement was for 2 separate agents one rewriting the sender domain and one rewriting the recipient domain.
The Project contains 2 Solutions; the way these agents works is the following.
If the email is sent TO <somerepicpient>@contoso.com then rewrite the recipient to <somerepicpient>@tailspintoys.com
If the email is sent FROM <somesender>@contoso.com then rewrite the sender as <somesender>@tailspintoys.com
Attached you can find the Visual Studio Project; this includes the Exchange 2013 Microsoft.Exchange.Data.Common and Microsoft.Exchange.Data.Transport DLL's.
The sample though, can be easily adapted to Exchange 2010 if necessary. To do so all that needs to be done consists in removing the 2 DLL's from the References (for each Solution), remove the files from .\<Solution>\Exchange, grab the same DLL's from C:\Program Files\Microsoft\Exchange Server\V14\Public and re-add them to the References (for each Solution).