Send HTML Formatted Exception Email? RRS feed

  • Question

  • User797956788 posted
    Is there a way to format the email that is sent when an error occurs in HTML?  I have an Email Sink setup to send me an email when ever appropriate exceptions occur on our web site, but reading an email that looks like an event log is rather annoying.

    I used to have a custom error handler that was very easy to read (formatted in HTML) and also included information about the users browser.  Would it be possible to create a 'Custom Formatter' that could send an HTML formatted email? If so, could someone start me in the right direction for doing that?
    Wednesday, July 13, 2005 3:03 PM

All replies

  • User797956788 posted
    Well, I figured it out.  Maybe not the best way possible, but I'm getting pretty HTML error messages via email [:D]

    First off, in the Logging project of the Enterprise Library solution, I added the following line of code to the Sinks\EmailMessage.cs file:

       60             message.Subject = sendToSmtpSubject;
       61             message.BodyFormat = MailFormat.Html;
       62             message.BodyEncoding = Encoding.UTF8;
    I then created a new Formatter (which I called "HTML Formatter") and added the appropriate HTML to make the message sent by the email sink look nice.  This is what I now get: (Sorry about the size!)

    Note that in the Message section, I wrapped the {message} tag with <code><pre></pre></code> to keep the nice format.

    Now if I could only figure-out how to get information about the user's browser added to this, I'd be set [;)]  I typically like to know which browser and version the user was using, their IP address, etc.
    Friday, July 15, 2005 10:39 AM