How to use a Text File as a Template to Send Email in C#



Login to See the Rest of the Answer

Answer:

1. Create a text file in your project

2. Code your template in the text file for example:

     <code>Name:  ##Name##
                  E-Maile:  ##Email##
                  Home Phone:  ##Phone##
                  Comments:   ##Comments##

</code>

3. Save and close

4. In your C# code read the text file using "using System.IO" and
string MyFile = Server.MapPath("~/App_Data/ContactForm.txt");
string mailMessage = File.ReadAllText(MyFile)
mailMessage = mailMessage.Replace(""##Name##,"Mack");
mailMessage = mailMessage.Replace(""##Name##,"Mack");


Technology
published
v.0.01




© 2024 - ErnesTech - Privacy
E-Commerce Return Policy