Matt Jenkins
Matt Jenkins

Reputation: 3081

Configure Elmah email settings in code rather than config

I'm setting up Elmah emails and I don't want to put my email account credentials in web.config.

I'm deploying on Azure and therefore would like to look up the credentials from Azure app settings in code on app startup.

Is there a way to configure Elmah emails declaratively in code rather than using the <errorMail> tag?

Upvotes: 0

Views: 583

Answers (2)

Jonathan Sayce
Jonathan Sayce

Reputation: 9679

The best way to do this is by overriding the SendMail method of Elmah's ErrorMailModule, as suggested by Atif Aziz in this discussion on Google Groups.

I've given more details in this answer.

Upvotes: 1

cdev
cdev

Reputation: 166

You could trap the Elmah Mailing event and substitute your email addresses.

http://scottonwriting.net/sowblog/archive/2011/01/06/customizing-elmah-s-error-emails.aspx

Upvotes: 0

Related Questions