tags:

views:

198

answers:

1

I'm using the errorMail functionality of Elmah to send an email when ASP.NET encounters an error. It allows you to configure the SMTP settings as well as hard-code a sender, recipient, and subject.

My question is: can I use a dynamic subject? Specifically, I would like to use the Exception.Message property as my subject, so that I can tell what the error is about just from the subject line of the email.

There is no documentation, and from a quick scan of the source code it looks impossible without modifying the code, but I thought I would ask the question anyways.

Relevant source code:

+5  A: 

Doh! Answer is on line 454 of ErrorMailModule.cs:

string subjectFormat = Mask.EmptyString(this.MailSubjectFormat, "Error ({1}): {0}");
mail.Subject = string.Format(subjectFormat, error.Message, error.Type)
                .Replace('\r', ' ')
                .Replace('\n', ' ');

You can use {0} for the message and {1} for the type.

Portman