EchoCoders.Notification.FluentEmail 1.0.0

dotnet add package EchoCoders.Notification.FluentEmail --version 1.0.0
                    
NuGet\Install-Package EchoCoders.Notification.FluentEmail -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EchoCoders.Notification.FluentEmail" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EchoCoders.Notification.FluentEmail" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EchoCoders.Notification.FluentEmail" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EchoCoders.Notification.FluentEmail --version 1.0.0
                    
#r "nuget: EchoCoders.Notification.FluentEmail, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=EchoCoders.Notification.FluentEmail&version=1.0.0
                    
Install EchoCoders.Notification.FluentEmail as a Cake Addin
#tool nuget:?package=EchoCoders.Notification.FluentEmail&version=1.0.0
                    
Install EchoCoders.Notification.FluentEmail as a Cake Tool

EchoCoders.Notification.FluentEmail

A Email Sending Package which supports both SMTP and Azure Communication Mail service. It supports Fluent API format to configure and send email.

Available Fluent Methods

Setup() This method will be used to setup related mail settings such as sender address, TO, CC, BCC, HTML supports etc.

FormatSubjet() With the help of this method, we can format the subject. It supports dynamic parameter placing with pattern matching. For an example, you have a configured subject as: "OTP for ##REASON##", then you can replace this ##REASON## with any of your dynamic parameter value with this method. The calling procedure is as follows:

var paramDictionary = new Dictionary<string, string>();

paramDictionary.Add("REASON", "Password Change");

.FormatSubject("OTP for ##REASON##", "##", paramDictionary)

After calling this method, the subject will transform to: "OTP for Password Change"

FormatBody() With the help of this method, we can format the body. It supports dynamic parameter placing with pattern matching same as FormatSubject(). For an example, you have a configured body as: <p>Dear ##NAME##,</p><p>Your OTP is ##OTP##</p>, then you can replace this ##OTP## with any of your dynamic parameter value with this method. The calling procedure is as follows:

var paramDictionary = new Dictionary<string, string>();

paramDictionary.Add("OTP", "123456");

paramDictionary.Add("NAME", "Mr. X");

.FormatBody("<p>Dear ##NAME##,</p><p>Your OTP is ##OTP##</p>", "##", paramDictionary)

After calling this method, the subject will transform to: <p>Dear Mr. X,</p><p>Your OTP is 123456</p>

SendMail() and SendMailAsync() two methods to send mail synchronuous or asynchronuous call.

Full Code to send mail via Azure Communication Mail

IFluentMailService mailService = new FluentAzureMailService(new AzureMailSettings(ConnectionString:"you_azure_mail_connection_string"));

var paramDictionary = new Dictionary<string, string>();
paramDictionary.Add("OTP", "123456");
paramDictionary.Add("NAME", "Mr. X");
paramDictionary.Add("REASON", "Password Change");

await mailService
    .Setup(
        "info@your_mail.com", //sender
        new List<string>{"sender@your_mail.com"}, //TO list
        new List<string>(), //CC list
        new List<string>(), //BCC list
        true // HTML Support or not
    )
    .FormatSubject("OTP for ##REASON##", "##", paramDictionary)
    .FormatBody("<p>Dear ##NAME##,</p><p>Your OTP is ##OTP##</p>", "##", paramDictionary)
    .SendAsync();

Full Code to send mail via SMTP

IFluentMailService mailService = new FluentSmtpMailService(new SmtpMailSettings("smtp_address", 587, "smtp_sender@mail.com","your_smtp_password"));

var paramDictionary = new Dictionary<string, string>();
paramDictionary.Add("OTP", "123456");
paramDictionary.Add("NAME", "Mr. X");
paramDictionary.Add("REASON", "Password Change");

await mailService
    .Setup(
        "info@your_mail.com", //sender
        new List<string>{"sender@your_mail.com"}, //TO list
        new List<string>(), //CC list
        new List<string>(), //BCC list
        true // HTML Support or not
    )
    .FormatSubject("OTP for ##REASON##", "##", paramDictionary)
    .FormatBody("<p>Dear ##NAME##,</p><p>Your OTP is ##OTP##</p>", "##", paramDictionary)
    .SendAsync();

EchoCoders.Notification.FluentEmail.DependencyInjection

There is a supplementary package which covers dependency injection in .NET Core framework. To inject the depdency we need to call following methods:

services.AddFluentAzureEmailService(new AzureMailSettings("your_connection_string"));
services.AddFluentSmtpEmailService(new SmtpMailSettings("your_smtp_address", 587, "smtp_user_name", "smtp_password"));

Supported .NET versions

.NET 8 and upper

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on EchoCoders.Notification.FluentEmail:

Package Downloads
EchoCoders.Notification.FluentEmail.DependencyInjection

An email sending package with fluent api which supports both SMTP and Azure Mail with dependency injection (DI)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 196 3/4/2025