The application includes:
The web app and background service projects use the library project to send emails. SMTP settings are included in a config file in the library project itself.
In this scenario, is there a way to bind ELMAH to pick up SMTP settings from the library project? Perhaps if there's a way to configure ELMAH through code (during Application_Start), it would help achieve what's intended.
Guidance much appreciated.
You might find some use out of [this article].
Particularly the section about sending error reports automatically through email might be useful for you. Here's a more focused link with the same topic: [link]
Although these show how to setup a static address for your SMTP settings, I'm not sure I know how to dynamically create them at run-time based on a config file. If I find a way to do this in a better way I'll be sure to edit this answer or post a comment, but take a look at the links to see if they help for now.
You can configure elmah to post the error report to an HTML address. See this article.
When you set it to post to that address, you can have whatever back end you want catch it and send the email for you.
You mentioned you're using MVC, so you could have elmah post to a controller action that would then send the email, using the SMTP settings from your library project since you'd have access to the references there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With