Custom Transport Agent to Rewrite From Address only for outgoing messages RRS feed

  • Question

  • I would like to write a custom transport agent in order to rewrite the from address in outgoing messages, but this must happen only for messages going to external recipients. Internal recipients must see the original sender. If a message contains both internal and external recipients, i need to rewrite the from address only on the message sent to the external recipient.

    On which event should I trigger the code to rewrite the from address fields? Based on the documentation i can use the following:

    Categorizer events

    Sequence Categorizer event Description



    This event is triggered upon submission of a message into the Submission queues on the receiving SMTP host. All messages encounter this event whether they arrived via SMTP submission, MAPI submission, or the Pickup or Replay directories.



    This event is triggered after all the recipients have been resolved, but before the next hop has been determined for each recipient. The OnResolvedMessage routing event enables subsequent events to override the default routing behavior by using the per-recipient SetRoutingOverride method.



    This event is triggered after messages have been categorized, distribution lists have been expanded, and recipients have been resolved.



    This event is triggered when the Categorizer completes processing the message.


    Monday, May 7, 2012 1:35 AM

All replies

  • Hmmm ... I can't recall if you can change that (and to clarify, are you referring to the MailItem.FromAddress in the envelope or MailItem.Message.From ?).

    Generally speaking the later the event, the less you can change (i.e. in OnSubmission you can change most things but in OnCategorized you can change very little), so I'd suggest you look at OnSubmission and probably use "fork" to split the email into two - one with internal and the other with external recipients.


    Scott Quinn | C# developer & messaging specialist (for hire). Contact me at

    Monday, May 7, 2012 8:57 AM