Enterprise Library .NET 2.0 Logging - HTML email

Posted on 2006-04-25
Last Modified: 2008-09-05
Looking for examples on how to send an HTML formatted email using Enterprise Library for .NET 2.0 (Jan 2006) in the Logging Application Block.

Most tutorials I have seen show text emails, which in my opinion are obvious since it comes set up for that.  Any ideas on how to customize the email format to HTML
Question by:mrichmon
    LVL 4

    Expert Comment

    I recommend you to create another "sink", for example, an HTMLEmailSink, and configure the LogStrategy to use that sink depending on the configuration.

    Another idea is to change the existing EmailSink. The text probably gets formatted there.

    I don't know exactly what you need, but those are interesting idea.

    Since the Enterprise Library sometimes need to be registered with strong name and any change make us re-register it all, I created my own Logging Application Block code. It's very simple and allows us to configure the logging, to create as many LogSinks as we need, to simply modify the LogStrategy and to avoid using the Configuration Application Block.

    LVL 35

    Author Comment


    Sinks are in .NET 1.1.  They are no longer present in the Logging Application Block for Enterprise Library for .NET 2.0  Instead there are Trace Listeners, Formatters, etc.

    As far as I have been able to determine there is no way to directly create html email messages.  The only option I see is to modify the Logging.Configuration.EmailMessage class to also take in a bit field indicating if you want HTML messages or Text messages.  Although I have not figured out how to then cause this change to be an option through the enterprise library configuration interface, only to manually modify the config file....

    Please read the question carefully and do not answer if you don't know the situation being discussed.
    LVL 35

    Author Comment

    Okay I found how to do this.  Not built in, but what I ended up doing was modifying Enterprise libarary to accept a parameter called IsBodyHtml.  I passed this parameter through all the way so that it can be accessed as a boolean field in the Enterprise Library confiuration program.

    No I can set a bit field per listener to achieve this.

    For others:

    The files I needed to modify in the Logging and related assemblies included:

    Accepted Solution

    Closed, 250 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now