Start New Discussion within our Software Development Community

Hi Folks,

I am trying to make default AppSettings in my App.Config.

My Program, or part of it, requires an email template and I wish to save this template within a HTML File on my HDD. In my App.Config, I simply want to specify multiple keys such as Subject, Recipient etc and then get the value for each of those keys from a file, where the file will look something like this:

<html>
 <head>
 </head>
 <body>
  <p><b>Name:</b> {%Name%}</p>
  <p><b>Job Title:</b> {%JobTitle%}</p>
  <p><b>Address Line 1:</b> {%AddressLine1%}</p>
  <p><b>Address Line 2:</b> {%AddressLine2%}</p>
  <p><b>Address Line 3:</b> {%AddressLine3%}</p>
  <p><b>City:</b> {%City%}</p>
  <p><b>County:</b> {%County%}</p>
  <p><b>Postcode:</b> {%Postcode%}</p>
  <p><b>Telephone:</b> {%Telephone%}</p>
  <p><b>Fax:</b> {%Fax%}</p>
  <p><b>Comments:</b> {%Comments%}</p>
 </body>
</html>

the [%....%] tags are place-holders for actual data. Again, the tasks here is to get these data from my C# App.Config program.

Any help is appreciated.

App.Config is probably a bad place to put this information as it's not designed to be variable.

if you still wish to go that way, it's simply ConfigurationManager.AppSettings["keyname"]

This article has been dead for over six months. Start a new discussion instead.