Introduction
This article explains how to send email from a C# WPF Windows Application using HTML Email Templates.
Using:
- HTML Email Templates
- MySQL Database
- WPF ApplicationFrom
Step 1: Design the HTML page with the following markup: “Event.Html”.
Integrated run HTML previewing pages “Event.Html”.
Step 2: Open MySQLAdmin Page then select "Create A New Table” -> "View" -> ”Table Structure for Table `Event`”.
CREATETABLEIFNOTEXISTS`Event`(
`Firstname` Varchar(100)NOTNULL,
`Lastname` Varchar(100)NOTNULL,
`Email` Varchar(25)NOTNULL,
`Mobile` Varchar(12)NOTNULL
)ENGINE=InnodbDEFAULTCHARSET=Latin1;
Step 3: View Table > “Event”. 
Step 4: Create a new project using "File" > "New" > "Project..." > "WPF Application".
Step 5: Now -> ”Toolbox” -> “Select” .
- 1 Button
- 2 Grid
- 5 Text block
- 4 TextBox
<Grid Height="350"Width="500"Background="#FFD1F9EE" >
<TextblockHeight="32"Horizontalalignment="Left"Margin="29,15,0,0"
<Grid Margin="31,0,29,95"Background="White"Height="180"
<Grid.Rowdefinitions>
<RowdefinitionHeight="250*" />
</Grid.Rowdefinitions>
<TextblockHeight="25"Horizontalalignment="Left"Margin="67,20,0,0"
<TextblockHeight="25"Horizontalalignment="Left"Margin="67,50,0,0"
<TextblockHeight="25"Horizontalalignment="Left"Margin="67,80,0,0"
<TextblockHeight="25"Horizontalalignment="Left"Margin="67,110,0,0"
<TextboxHeight="25"Horizontalalignment="Left"Margin="183,20,0,0"
<TextboxHeight="25"Horizontalalignment="Left"Margin="183,50,0,0"
<TextboxHeight="25"Horizontalalignment="Left"Margin="183,80,0,0"
<TextboxHeight="25"Horizontalalignment="Left"Margin="183,110,0,0"
<Button Content="Registration"Height="25"Horizontalalignment="Left"Margin="183,145,0,0"
</Grid>
<TextblockHeight="20"Horizontalalignment="Left"Margin="215,46,0,0"
</Grid>
Step 7: You will get the MainWindow.xaml window form.
Step 8: Use the following namespaces:
UsingSystem.Data;
UsingSystem.Drawing;
UsingSystem.Net;
UsingSystem.Configuration;
UsingSystem.Net.Mail;
UsingSystem.Text.Regularexpressions;
UsingMysql.Data.Mysqlclient;
Step 9: Use the following code for the Email:
Step 10: Use the following for “btnregistration_Click":


Step 11: Run the application and select “Registration Window Show”.

Step 12: “Registered Successfully”:

Step 13: Now seelct "Gmail Account Open" - > "View Email".

Now design the HTML PageEmail Templates, Create a MySQL table and send email from the C# WPF Windows Application using HTML Email Templates. I hope you enjoyed this article.

Join the conversation! Your thoughts help the community grow.