Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What are the alternatives to using hard coded email messages? 1

Status
Not open for further replies.

aspdotnetuser

Programmer
Oct 10, 2008
45
GB
Hi,

I currently have email messages hard coded into my files for emails that are automatically, i.e when a user registers their details to create an account.

What alternatives are there to this? Could I use a database to imrove on the existing method? would using separate basic textfiles be an improvement?

Any comments will be appreciated!
 
How specifically does it need improvement?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Basically, there are snippets of code dotted around in different files that send the appropriate emails when required.

The main objective is to make a method in the c# code in the class that all the other classes inherit from, and to bring the existing code up to date (System.Net.Mail, making use of <System.net> tag in web.config)

I suppose my question is really how can it be improved in terms of storing email templates? (the email message that gets sent to the user), if it can at all be improved over having the message in the c# file!
 
the beauty of programming is there is no "one way" depending on how you build your email messages would effect how you can better handle them.

there are 2 primary concerns
1. how to store the messages: database, external files, resource files, constant strings.
2. how to parse the file to use instance specific values: xml & xslt, regex, find/replace (which is simplified regex)

these concerns can be mixed and matched since where it's stored and how it's formatted are not related. another side note. neither of these concerns effects how this would interact with system.net app settings:) that deals with Message/SmtpClient objects, which doesn't care what the body is.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks again for the detailed answer ;-) I decided to make a new method in the super class that accepts email parameters one of which indicates the type of email to be sent. And the email messages will be stored in textfiles which include strings such as ##username## which will be replaced for each email.
 
Thanks again for the detailed answer ;-) I decided to make a new method in the super class that accepts email parameters one of which indicates the type of email to be sent. And the email messages will be stored in textfiles which include strings such as ##username## which will be replaced for each email using:

[blue]message.Body.Replace("##username##", username);[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top