Modify the Email Trace Listener

Topics: Logging Application Block
Aug 20, 2009 at 12:49 AM

I use the logging app block. I have a email trace listener. how ever, the email trace listener dont have its subject configurable. I want to modify the code of the email trace listener so that I can configure the subject from the tool but I can't get it right. Please help.

Aug 20, 2009 at 9:09 AM


This one takes extra effort to hit the desired output correctly. You would need to modify the ff classes:

  1. EmailTraceListenerData
  2. EmailTraceListener
  3. EmailTraceListenerAssembler
  4. EmailMessage
  5. EmailTraceListenerNode
  • In the EmailTraceListenerData class, you must add a new property (Subject), and add the subject as a parameter to the constructors.
        [ConfigurationProperty(subjectProperty, IsRequired = true)]
        public string Subject
            get { return (string)base[subjectProperty]; }
            set { base[subjectProperty] = value; }
  • In the EmailTraceListener class, you will also need to add the "subject" as parameter in the constructors.
  • In the EmailTraceListenerAssembler, you would need to add the "subject" in the creation of the traceListener.
	TraceListener createdObject = new EmailTraceListener(
  • In the EmailMessage, you would also modify the contructor to accept "subject" as parameter, also you should modify the CreateMailMessage() method, to assign the "subject" to the MailMessage.Subject.
  • In the EmailTraceListenerNode, you will add a "Subject" property, just like the other properties that you will see in the class.

NOTE: The "subject" im refering to is just a name, you can change it to whatever name you want.

 I would like to post all the code that is modified but it seems to be so long. We can send you the solution that we've modified if you want. Also, you can use this, its a custom email trace listener that can be plugged in to ent lib. you can view the source code on how the other properties was added for the trace listener.


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Aug 23, 2009 at 2:34 PM

Thanks very much. It works. Now I have the subject of the Email trace listener configurable.

Aug 24, 2009 at 2:05 AM

Just an additional, how can I make something configurable which the values will be selected from a dropdown, say for the Encoding of the the Mailmessage of the Email trace listener?

Aug 24, 2009 at 12:56 PM


I was not successful in my initial attempt to create a property that is configurable via dropdown. I'm still continuing my testing and investigation for this. One thing that I saw in the ent lib source code. In the class TraceListenerNode. The property Filter is a enum which is configurable from the UI. I'm not sure if it is also possible with the non enum types. Could you please try that one out. I get back to you if I make this one work.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Sep 7, 2009 at 1:17 AM

Any updates?

Sep 7, 2009 at 7:44 AM


What you can do is create your custom enum type, the in the listenerNode class, say EmailTraceListenerNode. Declare a property with the type of your custom enum type.


I create a "MailEncoding" class which will be the options in the config.

public enum MailEncoding
In the EmailTraceListenerNode:
        [SRDescription("EmailTraceListenerMailEncodingDescription", typeof(Resources))]
        [SRCategory("CategoryGeneral", typeof(Resources))]
        public MailEncoding Encoding
            get { return encoding; }
            set { encoding = value; }
I have this property. Dont forget to set the ([DefaultValue(MailEncoding.UTF32)]) default value for the dropdown. The just implement codes that will pass those
from the config tool to the trace listener object.
Valiant Dudan
Global Technology and Solutions
Avanade, Inc.