These days nearly every business application involves some form of communication via email. Something I encounter all too frequently (and have even been guilty of myself) is hard-coding email addresses into applications. The main problem with this is that you have to alter the source code when an address needs to be changed or when a recipient needs to be added or removed. Altering source code, in many cases, means that applications will have to be recompiled (especially in the case of ASP.NET sites).
Generally you will want to store your email addresses in some kind of configuration source, whether that be a database, a config file or just a plain old XML file. You’ll have to examine your situation and determine the best solution. For .NET applications, projects generally come with some form of “app.config” or “web.config” where you can add configuration entries in a variety of ways:
- Simple and Quick: http://geekswithblogs.net/akraus1/archive/2006/01/04/64871.aspx
- Creating Custom Sections: http://www.codeproject.com/Articles/10981/Understanding-Section-Handlers-App-config-File
- Creating Custom Section Types: http://www.4guysfromrolla.com/articles/032807-1.aspx
Even if you’re not working with code that needs to be compiled, it’s still nice for your users and future maintainers (and even yourself after not having looked at the application in a year or so) to keep all of the configurable settings in one accessible location. Creating a simple XML file goes a long ways towards keeping settings organized and structured, and just about every language and environment has some form of XML parsing/recognition.