Ernes
Tech
Register
Login
Jobs
Search
Articles
Videos
Shop
0
Home
Articles
Details
+1 (216)-435-0788
How to use a Text File as a Template to Send Email in dotnet core 2
Login to See the Rest of the Answer
Answer:
One way to accomplish this is by creating a text file and defining your template wrapped in a pair of double hash symbols
For Example:
Name: ##Name##
E-Mail Address: ##Email##
Home Phone: ##Phone##
Comments: ##Comments##
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##","
[email protected]
");
Go on and implement this until you see fit.
Write an Article
Written By:
Ernes
SoftwareDeveloper
Views:
385
74
Notify Me of New Posts
×
We Recieved Your Request. Thank you.
We'll never share your email with anyone else.
Submit
You Liked This Article
Post Comment
Upload
How to Inject Custom Http Response Header
Views
1435
How to Find Maximum Number in an Array in C#
Views
1016
Error g.cshtml.cs: The type or namespace name ErrorViewModel could not be found (are you missing a using directive or an assembly reference). File Error.g.cshtml.cs
Views
2601
Solved!! A local or parameter named cannot be declared in this scope
Views
3699
Invalid Operation Exception, the Model Item Passed In To View is of Type
Views
2420
Google
LinkedIn
Microsoft
GitHub
Google
LinkedIn
Microsoft
GitHub
Top
© 2023 - ErnesTech -
Privacy
+1 (216)-435-0788
[email protected]
English (United States)
Spanish (Spain)
French (France)
Portuguese (Brazil)
Chinese (China)
Turkish (Turkey)
German (Germany)
Jobs
Search
CRM
Articles
Videos
Shop
Contact
Sign Up
Login
Grid-Method Tools
PDF to HTML Converter
Forums