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

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");


Edit this Article
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy