Dynamically change the subject for EmailSinkData in EntLibrary June 2005 for .net frameWork1.1

Topics: Exception Handling Application Block
Jan 8, 2014 at 10:32 AM
Hello

We are using EnterpriseLibraryJune2005 in our web application for exception logging with .net framework 1.1. The problem is when ever we get an exception we need to mention the database ,server name and error details as subject in email which has sent from EnterpriseLibrary.For now with email sink database feature by default "error" is sent as subject.But we need to change the subject dynamically based on error.Please help me to out from this problem.

Thanking u advance.
Jan 9, 2014 at 1:00 PM
I think you could achieve what you want using programmatic configuration of the block. However, you would have to reconfigure the block every time you want to send an email so it's not an ideal solution (also, you wouldn't want to use that approach in a multi-threaded environment such as a web application).

A better approach would be to create a a custom log sink to do exactly what you want. That way you can set the email subject to the appropriate value based on the LogEntry information.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jan 10, 2014 at 10:23 AM
Thank you randy .You are right.Actually I tried the same like accessing the config file and change the SubjectLineStarter and SubjectLineEnder properties dynamically save that config file and then calling Exception handling function.It is working great for one user.If there is more than one exception occurring at the same time causes to send the subject of 2nd email as first email subject even though we are implementing locking mechanism while saving config file and calling Handling function.But we fail to do so.

So as you said it is possible to do with custom log sink. I have searched for sample POC to change the subject of email using custom Log Sink.But my attempts are vain. Would you please provide me a sample code to create custom log sink for changing the subject of an email( for .net framework1.1 application).?


I appreciate your support.


Thank you.
Regards,
Sai Prathap
Jan 11, 2014 at 3:22 AM
Edited Jan 11, 2014 at 3:22 AM
This Hands on Lab has an example of creating and using a custom sink.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jan 17, 2014 at 1:14 PM
Sorry for the late reply.Thank u randy for ur support.