0

I have an Exception Handler that email our Help Desk software whenever there is an error. All properties for the Mailer are handled in app.config. One of which looks like this --> <add key="from" value="MATRIX@Exception.Handler"/>

Is there a way to have the value set to Environment.Username + '@ourcompany.org.

As a side note this is an internal app only.

Refracted Paladin
  • 11,636
  • 32
  • 115
  • 224

2 Answers2

1

Use the Macro pattern. Set the value to be [User]@Exception.Handler, then wrap it in a helper method. Add String.Replace("[User]", Environment.Username) in the helper, and you are good to go.

Always wrap configuration values in helper method. This allows you to convert from string to other type, check for invalid values, substitute defaults, etc. Configuration files frequently are incorrect or mangled causing difficult-to-diagnose runtime errors.

Jennifer Zouak
  • 1,318
  • 6
  • 12
0

This is not possible.
You will need to modify the code that reads the value.

SLaks
  • 800,742
  • 167
  • 1,811
  • 1,896