Edi.TemplateEmail
2026.5.0
See the version list below for details.
dotnet add package Edi.TemplateEmail --version 2026.5.0
NuGet\Install-Package Edi.TemplateEmail -Version 2026.5.0
<PackageReference Include="Edi.TemplateEmail" Version="2026.5.0" />
<PackageVersion Include="Edi.TemplateEmail" Version="2026.5.0" />
<PackageReference Include="Edi.TemplateEmail" />
paket add Edi.TemplateEmail --version 2026.5.0
#r "nuget: Edi.TemplateEmail, 2026.5.0"
#:package Edi.TemplateEmail@2026.5.0
#addin nuget:?package=Edi.TemplateEmail&version=2026.5.0
#tool nuget:?package=Edi.TemplateEmail&version=2026.5.0
Edi.TemplateEmail
This library enable you to configure email in XML template and send the email in your .NET applications.
SMTP sending is available through the
Edi.TemplateEmail.Smtppackage.
Install
dotnet add package Edi.TemplateEmail
dotnet add package Edi.TemplateEmail.Smtp
Usage
Step 1: Put a mailConfiguration.xml somewhere you like
<?xml version="1.0"?>
<MailConfiguration>
<MailMessage MessageType="TestMail" IsHtml="true">
<MessageSubject>Test Mail on {MachineName.Value}</MessageSubject>
<MessageBody>
<![CDATA[
Mail configuration on {MachineName.Value} is good: <br />
Smtp Server: {SmtpServer.Value}<br />
Smtp Port: {SmtpServerPort.Value}<br />
Smtp Username: {SmtpUserName.Value}<br />
Email Display Name: {EmailDisplayName.Value}<br />
SMTP security: {SocketOptions.Value}<br />
]]>
</MessageBody>
</MailMessage>
</MailConfiguration>
Step 2:
Initialize the EmailHelper by your mail server settings
using MailKit.Security;
// Change these values
var smtpServer = "smtp.example.com";
var userName = "test1@example.com";
var password = "********";
var port = 587;
var toAddress = "test2@test.com";
var fromAddress = "notifications@example.com";
var displayName = "Test Sender";
var configSource = $"{Directory.GetCurrentDirectory()}\\mailConfiguration.xml";
var emailSettings = new EmailSettings
{
FromAddress = fromAddress,
EmailDisplayName = displayName,
SmtpSettings = new(smtpServer, userName, password, port)
{
SocketOptions = SecureSocketOptions.StartTls
}
};
var emailHelper = new EmailHelper(configSource);
FromAddress is required and is independent of the SMTP login. EmailDisplayName is the display name for this address. Set the SMTP user name to null or an empty string to send without authentication; authenticated user names do not have to be email addresses.
When sending on behalf of another address, optionally set SenderAddress and its display name, SenderName. The Sender header is omitted when SenderAddress is not configured:
emailSettings.SenderAddress = "mailer@example.com";
emailSettings.SenderName = "Mail Service";
When upgrading, explicitly set FromAddress (usually to the email address previously used as the SMTP user name). Set SenderAddress as well if you need the previous Sender header; SenderName alone no longer adds it.
Set SmtpSettings.SocketOptions to the connection mode required by your SMTP server:
| Mode | Behavior |
|---|---|
StartTls (default) |
Requires STARTTLS; fails if unsupported. Commonly used on port 587. |
SslOnConnect |
Uses TLS immediately upon connection. Commonly used on port 465. |
None |
Uses an unencrypted connection. |
StartTlsWhenAvailable |
Uses STARTTLS if supported; otherwise continues unencrypted. |
Auto |
Selects SslOnConnect on port 465 and StartTlsWhenAvailable on other ports. |
For port 465, set the port to 465 and SocketOptions to SecureSocketOptions.SslOnConnect. Auto and StartTlsWhenAvailable permit unencrypted connections; choose StartTls or SslOnConnect when encryption is required. See the MailKit connection documentation.
EnableTls has been removed. Replace EnableTls = true with SocketOptions = SecureSocketOptions.StartTls. The previous EnableTls = false behavior corresponds to SocketOptions = SecureSocketOptions.Auto; use None only when an unencrypted connection is intended. SkipCertificateValidation remains disabled by default and is for development only.
Step 3: Map the values and send Email
var message = emailHelper.ForType("TestMail")
.Map("MachineName", Environment.MachineName)
.Map("SmtpServer", emailSettings.SmtpSettings.SmtpServer)
.Map("SmtpServerPort", emailSettings.SmtpSettings.SmtpServerPort)
.Map("SmtpUserName", emailSettings.SmtpSettings.SmtpUserName)
.Map("EmailDisplayName", emailSettings.EmailDisplayName)
.Map("SocketOptions", emailSettings.SmtpSettings.SocketOptions)
.BuildMessage([toAddress]);
var result = await message.SendAsync(emailSettings);
Token values
Tokens use {Entity.Property} with case-sensitive names. Map an entity before calling BuildMessage:
var message = emailHelper.ForType("TestMail")
.Map("SentAt", DateTime.Now)
.Map("User", new { Name = "Alice" })
.BuildMessage([toAddress]);
{SentAt.Value}uses the mapped value'sToString(), including dates, numbers, enums, and objects. Formatting uses the value's normalToString()behavior and current culture where applicable.Valueis reserved for the whole mapped value, even when the object has a property namedValue. To render that property, map its value separately, for example.Map("Amount", model.Value)and use{Amount.Value}.- Other property names, such as
{User.Name}, read public instance getters without index parameters. Indexers, static properties, and properties without a public getter return an empty string. Exceptions thrown by a readable getter still propagate. - Strings return the mapped string for any property name. Values without public properties retain the
ToString()fallback for any property name. - Missing entities or properties and null mapped or property values produce an empty string.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Edi.TemplateEmail:
| Package | Downloads |
|---|---|
|
Edi.TemplateEmail.Smtp
SMTP email sending extension for Edi.TemplateEmail using MailKit |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.8.0 | 198 | 11/5/2026 |
| 2026.7.0 | 123 | 11/4/2026 |
| 2026.6.0 | 112 | 11/4/2026 |
| 2026.5.0 | 112 | 11/3/2026 |
| 2026.4.3 | 107 | 11/3/2026 |
| 2026.4.2 | 923 | 5/30/2026 |
| 2026.4.1 | 157 | 4/18/2026 |
| 2026.4.0 | 204 | 3/28/2026 |
| 2026.3.0 | 173 | 3/18/2026 |
| 2026.2.0 | 150 | 3/11/2026 |
| 2026.1.0 | 146 | 2/28/2026 |
| 2025.5.0 | 439 | 11/13/2025 |
| 2025.4.0 | 308 | 7/2/2025 |
| 2025.3.0 | 287 | 6/6/2025 |
| 2025.2.0 | 376 | 2/25/2025 |
| 2025.1.0 | 230 | 1/6/2025 |
| 2024.6.0 | 251 | 11/13/2024 |
| 2024.5.0 | 268 | 10/11/2024 |
| 2024.4.0 | 222 | 10/10/2024 |
| 2024.3.0 | 237 | 10/10/2024 |