Ernes
Tech
Register
Login
AI
Search
News
Articles
Videos
2
Home
Articles
Details
+1 888-688-2939
[email protected]
.Net 7
189
AI
114
Technology
105
Other
86
SQL
58
Servers
52
Research
45
Questions
35
Jobs
35
Databases
35
Entity Framework
29
Programming
27
Docker
26
Linux
25
Network
20
Machine Learning
19
Android
19
Home
16
C-Sharp
13
Art
12
Windows
12
JavaScript
11
Lipedema
9
System Design
8
HTML5
8
Candles
8
Docker Compose
7
Tutorials
7
MVC
7
Tools
6
Algorithms
6
General
6
Hardware
6
.NET 5
5
Bootstrap
5
G
4
Health
2
Voip
1
Self-Help
1
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.
#Technology
.Net 7
published
v.0.01
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
How to Use a well Known Drawing Method to Achieve
How to Use a well Known Drawing Method to Achieve Realism in Drawing
ART
Read Article
Dotnet 8 publishing Self-Contained Application not
Dotnet 8 publishing Self-Contained Application not Working
OTHER
Read Article
How to read an Email Header
How to read an Email Header
RESEARCH
Read Article
How to Use 2 CTE in a Single SQL Query - Use Temp
How to Use 2 CTE in a Single SQL Query - Use Temp Table Instead
SQL
Read Article
How to Remove Duende IdentityServer from Blazor We
How to Remove Duende IdentityServer from Blazor Web Assembly Application in Visual Studio 2022
.NET 7
Read Article
How to Prepare a Reference Photo for Drawing
How to Prepare a Reference Photo for Drawing
ART
Read Article
Vmware ESXI 6.2 How to Mount a USB Storage to vmwa
Vmware ESXI 6.2 How to Mount a USB Storage to vmware esxi host
HARDWARE
Read Article
How to use a Text File as a Template to Send Email
How to use a Text File as a Template to Send Email in C#
TECHNOLOGY
Read Article
Asp.Net 5 Development Notes (DotNet Core 3.1 Study
Asp.Net 5 Development Notes (DotNet Core 3.1 Study Notes)
SOFTWARE DEVELOPMENT
Read Article
How you parse a collection of email addresses with
How you parse a collection of email addresses with mimekit?
TECHNOLOGY
Read Article
MSB1009: Docker File Error when building Asp.Net 5
MSB1009: Docker File Error when building Asp.Net 5
.NET 7
Read Article
How to Bind a CheckBox data to a Model Integer Pro
How to Bind a CheckBox data to a Model Integer Property in DotNet Core 2.2
DATABASES
Read Article
[Resolved] Dot Net Core Error "Project file is inc
[Resolved] Dot Net Core Error "Project file is incomplete. Expected imports are missing"
.NET 7
Read Article
MSBUILD : error MSB1009: Project file does not exi
MSBUILD : error MSB1009: Project file does not exist. Switch: ProjectName.csproj
.NET 7
Read Article
Login to Continue, We will bring you back to this content
0
Google
Microsoft
GitHub
Google
Microsoft
GitHub
Top
© 2025 - ErnesTech -
Privacy
E-Commerce Return Policy
+1 (216)-435-0788
[email protected]
For peering opportunity
Autonomouse System Number:
AS401345
[email protected]
English (United States)
Spanish (Spain)
French (France)
Portuguese (Brazil)
Chinese (China)
Turkish (Turkey)
German (Germany)
Jobs
Search
CRM
Tools
Articles
Videos
Shop
Contact
Sign Up
Login
Grid-Method Tools
PDF to HTML Converter
Forums