Sample Exchange 2007 transport agent – add the name of the group to subject line

Many people use rules to automatically sort messages from various distribution lists into folders in order to keep the volume of email traffic in their inbox to a manageable level. This works for the most part - until someone decides to BCC a list. Since the distribution list isn't visible in the list of recipients, it bypasses all rules and gets dropped in their inbox. This can cause quite a distraction for everyone on that DL because something appeared in their inbox, and it's not quite apparent why they received that message.

Mailman and Majordomo have had this problem solved for a while now. It's actually a very simple solution: make sure the name of the mailing list is included in the subject of the email. Then users can set up filters based on words in the subject and they never encounter the problem when someone BCC's the list.

Exchange 2007 can do the same thing; it just needs a little help from a custom transport agent. I have written a very basic agent to add the name of the DL into the subject. You can use it as a starting point and add your own features.

To install this agent, follow these instructions:

  1. Copy ShowDLInSubjectAgent.dll to your transport server. In this example, I place it in C:\MyAgents
  2. Open the Exchange Management Shell
  3. Type Install-TransportAgent -Name ShowDLInSubjectAgent -TransportAgentFactory ShowDLInSubjectAgent.ShowDLInSubjectFactory -AssemblyPath C:\MyAgents\ShowDLInSubjectAgent.dll
  4. Close and restart the Exchange Management Shell.
  5. Type Enable-TransportAgent -Identity ShowDLInSubjectAgent
  6. Restart the transport service by typing Restart-Service MSExchangeTransport

If all goes well, all emails to a distribution list will now include the name of the DL in the subject of the email.

Note: This is a sample transport agent and it is not officially supported by Microsoft. Please see the readme.txt file included in the package for more information.

The ZIP file with the binary and the entire source for you to play with is here:

- Jesse Weigert

Comments (8)
  1. Frank says:

    Amazing, the day this was posted we were trying to figure out how to do this exact thing with Exchange 2007.


  2. Brian Kronberg says:

    What does it do when the email is sent to multiple DLs?

  3. Jesse Weigert says:

    The transport agent will add every DL listed in the To, CC and BCC fields to the subject.  Nested DLs will not be added.

  4. jader3rd says:

    This sounds like the wrong solution to the problem. Why not have Exchange look at every message I recieve where I am not mentioned on the To: or CC: lines, that begins with Re: and see if the rest of the subject matches a message thread somewhere in one of my folders. Yes, that will be a perf hit in delivering the message, but since it’s probably going to a DL I don’t check that often I’m not going to notice the perf hit, since I’m not following the thread anyway.

  5. Jan Boguslawski says:

    Hi, is there any way to write a Custom Transport Agent that can change the display name part of the sender address? We like to use the Simple Display Name for outgoing mails, like it was possible with Exchange 2003.

    The technet article Planning for Address Rewriting comment’s: Outbound-only address rewriting cannot affect the user name or display name part of the address.

    Is this also true with a Custom Transport Agent?

    Can give me some helpful hints please?

    Best regards,


  6. Neilat says:

    I am setting up a transport agent but when I tried to install it I got this error message:

    Install-TransportAgent : Invalid agent configuration in file ‘E:MicrosoftExchange ServerTransportRolesagents.config’

    Do I have to edit this config file manually?



  7. crnx says:


    i got the same problems, did you solve this problem?

  8. yesso says:


    every time if i install the transport agent, the "microsoft exchange transport" service stops…what can the reason be?


Comments are closed.

Skip to main content