I’ve been continuing on with building and learning about Transport Agents over the past couple of weeks and thought I’d share an agent I’ve found useful. The following agent is a simple archiving agent it saves the serialized version of the message from the Mimedocument class to an eml file in a directory assigning it a GUID as a filename to make sure its unique. It also enumerates though the attachments of a message and saves them to a separate directory using the attachment filename and the message guid to link the message and attachments. I also added some code into to delete pdf files that where smaller than 20 KB this was for testing purposes but it’s something I’ve used in the past in SMTP sinks to overcome certain issues. Like the last Agent I posted this is a Routing agent I’m running on Hub Server the code is relatively simple to follow. To do the attachment processing I’ve used the new EmailMessage class that’s part of the Microsoft.Exchange.Data.Transport.Email namespace.