Join the Community
How to use a Text File as a Template to Send Email in dotnet core 2
Login to See the Rest of the Answer
One way to accomplish this is by creating a text file and defining your template wrapped in a pair of double hash symbols
E-Mail Address: ##Email##
Home Phone: ##Phone##
After you create a text file in your project and have typed your template as shown in 2, then you would write your C# code like this;
using System.IO // For reading the file
using System.Net.Mail //Sending the Email
//First read the file
string myFile = Server.MapPath("~/App_Directory/YourTextFileName.txt");
string mailBody = File.ReadAllText(myFile);
mailBody = mailBody.Replace("##Name##","Jack");
mailBody = mailBody.Replace("##E-Mail Address##","
Go on and implement this until you see fit.
Write an Article
Notify Me of New Posts
We Recieved Your Request. Thank you.
We'll never share your email with anyone else.
You Liked This Article
No Login Required!
If you log in, you will be notified when someone leaves a comment.
Other users would like to know if this solution helped you.
Login With Google
Login With LinkedIn
Login With Microsoft
Login With GitHub
© 2023 - ErnesTech LLC-
English (United States)
PDF to HTML Converter
How Can We Improve this Site?
2 + 4 =