FluentEmailer.LJShole 1.1.1

dotnet add package FluentEmailer.LJShole --version 1.1.1
                    
NuGet\Install-Package FluentEmailer.LJShole -Version 1.1.1
                    
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="FluentEmailer.LJShole" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentEmailer.LJShole" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="FluentEmailer.LJShole" />
                    
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 FluentEmailer.LJShole --version 1.1.1
                    
#r "nuget: FluentEmailer.LJShole, 1.1.1"
                    
#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.
#:package FluentEmailer.LJShole@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FluentEmailer.LJShole&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=FluentEmailer.LJShole&version=1.1.1
                    
Install as a Cake Tool

FluentEmailer

Fluent API to send emails in a .NET Core application using your own SMTP settings

V 1.1.1 Changes

This change addresses an issue with setting the Bcc and Cc email addresses before this change. These were added onto the To email list.

This change also includes a change to the .FromMailAddresses method; since an email can only originate from one email address, this method should be named accordingly i.e in singular form not plural.

Usage (using string as body of email)
_fluentEmail
    .UsingSMTPServer(hostName, portNumber, userName, password, sslRequired)
    .Message("Email Subject", new List<MailAddress> { new(toEmail) }, new(userName, "Email Display Name"))
    .FromMailAddress(new MailAddress(***userName***))             
    .Body("Test body content")
    .Send();

V 1.1.0 Changes

Future versions of the application / package will provide support for SendGrid, with this in mind, I have introduced breaking changes which pave way for the coming support. In addition, the change aims to make using the package much more intuitive and seemless. We do still support dependency injection. Simply add sample code below in your program.cs and import the FluentEmailer.LJShole namespace in the program.cs file.

builder.Services.AddFluentEmailer()

This will allow you to inject the IFluentEmail interface which you can use your code.

Usage (using string as body of email)
    _fluentEmail
      .UsingSMTPServer(hostName, portNumber, userName, password, sslRequired)
      .Message("Email Subject", new List<MailAddress> { new(toEmail) }, new(userName, "Email Display Name"))
          .FromMailAddresses(new MailAddress(***userName***))
          .CcMailAddresses([new MailAddress(***ccEmail***)])
          .BccMailAddresses([new MailAddress(***bccEmail***)])
          .AddAttachments([new($"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SamplePDF.pdf")}")])
      .Body("Test body content")
      .Send();
Usage (providing a template file for the body of the email)
     var templateValues = new Dictionary<string, string> { { "{{subject}}", "Testing Message" }, { "{{body}}", "<section><h2>This is</h2><p>Welcome to our world</p></section>" } };

     _fluentEmail
      .UsingSMTPServer(hostName, portNumber, userName, password, sslRequired)
      .Message("Email Subject", new List<MailAddress> { new(toEmail) }, new(userName, "Email Display Name"))
          .FromMailAddresses(new MailAddress(***userName***))
          .CcMailAddresses([new MailAddress(***ccEmail***)])
          .BccMailAddresses([new MailAddress(***bccEmail***)])
          .AddAttachments([new($"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SamplePDF.pdf")}")])
      .Body(templateValues, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestHtmlPage.html"))
      .Send();

V 1.0.4

Usage (Simple string as body of the email)
    new Mailer()
      .Message()
        .WithSubject("Email Subject")
        .AddFromMailAddresses(new MailAddress(userName))
        .AddToMailAddresses(new List<MailAddress> { new MailAddress(toEmail) })
        .WithBody()
            .UsingString("Email body as string")
        .SetBodyIsHtmlFlag()
      .WithCredentials()
        .UsingHostServer(hostName)
        .OnPortNumber(portNumber)
        .WithUserName(userName)
        .WithPassword(password)
      .Send();

hostName The SMPT/IMAP server you'll be using to send emails from. <br/> portNumber The port number used by the hostName<br/> userName The email address you'll be using to send emails from as configured on *hostName. <br/> password The password used to log in when accessing the email address (userName)<br/>

Usage (Providing a template file)
  new Mailer()
    .Message()
        .WithSubject("Email Subject")
        .AddFromMailAddresses(new MailAddress(userName))
        .AddToMailAddresses(new List<MailAddress> { new MailAddress(***toEmail***) })
        .AddCcMailAddresses(new List<MailAddress> { new MailAddress(***ccEmail***) })
        .AddBccMailAddresses(new List<MailAddress> { new MailAddress(***bccEmail***) })
        .WithBody()
            .UsingEmailTemplate($"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"TestHtmlPage.html")}")
            .UsingTemplateDictionary(new Dictionary<string, string> { { "{{subject}}","Testing Message"}, { "{{body}}", "<section><h2>This is</h2><p>Welcome to our world</p></section>" } })
            .CompileTemplate()
        .SetBodyIsHtmlFlag()
   .WithCredentials()
        .UsingHostServer(hostName)
        .OnPortNumber(portNumber)
        .WithUserName(userName)
        .WithPassword(password)
    .Send();
    

This usage requires a Dictionary<string,string> where the keys in the dictionary represent placeholders in the template to be replaced by their respective values.<br/>

Usage (Adding Attachments)
    new Mailer()
            .Message()
            .WithSubject("Mail Subject Template")
            .AddFromMailAddresses(new MailAddress(userName,"Fluent Email"))
            .AddToMailAddresses(new List<MailAddress> { new MailAddress(***toEmail***) })
            .AddCcMailAddresses(new List<MailAddress> { new MailAddress(***ccEmail***) })
            .AddBccMailAddresses(new List<MailAddress> { new MailAddress(***bccEmail***) })
            .WithAttachments(new List<Attachment> { new Attachment($"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SamplePDF.pdf")}") })
            .WithBody()
                    .UsingEmailTemplate($"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"TestHtmlPage.html")}")
                    .UsingTemplateDictionary(new Dictionary<string, string> { { "{{subject}}","Testing Message"}, { "{{body}}", "<section><h2>This is</h2><p>Welcome to our                                 world</p></section>" } })
                    .CompileTemplate()
            .SetBodyIsHtmlFlag()
            .WithCredentials()
                    .UsingHostServer(hostName)
                    .OnPortNumber(portNumber)
                    .WithUserName(userName)
                    .WithPassword(password)
            .Send();
            
            

V 1.0.3 Changes

    new Mailer()
        .SetUpMessage()
            .WithSubject("Mail Subject")
            .AddFromMailAddresses(new MailAddress(userName, "Fluent Email - No Attachments - With ReplyTo"))
            .AddToMailAddresses(new List<MailAddress> { new MailAddress(toEmail) })
            .SetSubjectEncoding(Encoding.UTF8)
            .WithReplyTo(new MailAddress("info@creativemode.co.za"))
            .SetUpBody()
                .SetBodyEncoding(Encoding.UTF8)
                .SetBodyTransferEncoding(TransferEncoding.Unknown)
                .Body()
                    .UsingString("This is me Testing")
                    .SetBodyIsHtmlFlag()
                    .SetPriority(MailPriority.Normal)
        .WithCredentials()
            .UsingHostServer(hostName)
            .OnPortNumber(portNumber)
            .WithUserName(userName)
            .WithPassword(password)
        .Send();
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net10.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 144 3/16/2025
1.1.0 81 3/15/2025
1.0.4 580 3/15/2021
1.0.3 439 1/16/2021
1.0.2 460 1/9/2021
1.0.1 499 1/9/2021

V 1.1.1 Changes
This change addresses an issue with setting the Bcc and Cc email addresses before this change. These were added onto the To email list.

This change also includes a change to the .FromMailAddresses method; since an email can only originate from one email address, this method should be named accordingly i.e in singular form not plural.

V 1.1.0 Changes
- Future versions of the application / package will provide support for SendGrid, with this in mind, I have introduced breaking changes which pave way for the coming support. In addition, the change aims to make using the package much more intuitive and seemless. We do still support dependency injection.

V1.0.4
- Added an overload when specifying the template location to allow the user to provide the templateValues on the same line of code.

V 1.0.3

- Added support for Reply-To field,
- Support for subject encoding.
- Support for both body encoding and body transfer encoding.