Link to home
Start Free TrialLog in
Avatar of mrichmon
mrichmon

asked on

Enterprise Library .NET 2.0 Logging - HTML email

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
Avatar of fcnatra
fcnatra
Flag of Spain image

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.

Avatar of mrichmon
mrichmon

ASKER

Cnatra,

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.
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:
EmailMessage.cs
EmailTraceListener.cs
EmailTraceListenerData.cs
EmailTraceListenerNode.cs
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial