Fusonic.Extensions.Email 8.1.3

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Fusonic.Extensions.Email --version 8.1.3
NuGet\Install-Package Fusonic.Extensions.Email -Version 8.1.3
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="Fusonic.Extensions.Email" Version="8.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fusonic.Extensions.Email --version 8.1.3
#r "nuget: Fusonic.Extensions.Email, 8.1.3"
#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.
// Install Fusonic.Extensions.Email as a Cake Addin
#addin nuget:?package=Fusonic.Extensions.Email&version=8.1.3

// Install Fusonic.Extensions.Email as a Cake Tool
#tool nuget:?package=Fusonic.Extensions.Email&version=8.1.3

Email

Setup

The following sample binds settings from the configuration located in the section "Email" using SimpleInjector.

The settings contain sender Email and name, SMTP settings, Debug settings and CSS settings. Check the EmailSettings class for details.

container.RegisterEmail(options => Configuration.GetSection("Email").Bind(options));

Create and send an email

To add new emails, following steps need to be done:

  1. Add a new View (.cshtml) in the directory Views/Emails/.
  2. Add a new ViewModel in the same namespace as the business logic that needs to send the mail.
  3. Add the EmailView attribute to the ViewModel. The constructor argument is path to the view, relative to the Views directory without the .cshtml extension. Example: [EmailView("Emails/Registration")] points to Views/Emails/Registration.cshtml.
  4. Extend the EmailController with a new method to render the view file and return the contents.
  5. To send the mail in the business logic use the MediatR-command SendEmail and supply it with the view model. SendEmail renders the mail based on the view model and the EmailViewAttribute.

To check the visuals of the view file, use the Swagger API to access the methods of the EmailController.

View locations

The views that are used for the emails are configured on the EmailViewAttribute. To find the view, the Razor view engine looks in the folder Views by default. A view path of Emails/FancyEmail matches to Views/Emails/FancyEmail.cshtml.

If you want to place the Views in other folders, for example /Emails, you can simply configure this in the Razor options as follows:

services.Configure<RazorViewEngineOptions>(options => options.ViewLocationFormats.Add("/Emails/{0}" + RazorViewEngine.ViewExtension));

Attachments

By default, only attachments in file://-Uris are supported. To allow adding attachments from other sources (eg. AWS S3), implement IEmailAttachmentResolver and register it SimpleInjector with

container.Collections.Append<IEmailAttachmentResolver, YourResolver>()

Headers

No special Headers are sent per default, however with the Headers parameter on SendEmail, MimeKit.Headers can be added to the email (overrides all Headers defined in EmailOptions.DefaultHeaders). With EmailOptions.DefaultHeaders default headers can be set for all emails. Predefined sets of headers can be found in EmailHeaders:

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. 
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
9.0.0-preview.1 44 4/5/2024
8.1.3 122 3/27/2024
8.1.2 89 3/27/2024
8.1.1 97 3/1/2024
8.1.0 374 1/26/2024
8.0.1 153 12/18/2023
8.0.1-rc.2 71 12/7/2023
8.0.1-rc.1 63 12/6/2023
8.0.0 208 11/21/2023
8.0.0-preview1 86 10/4/2023
7.4.0 80 1/25/2024
7.3.0 173 10/11/2023
7.2.1-rc.1 83 8/28/2023
7.2.0 360 6/28/2023
7.2.0-alpha.1 74 6/27/2023
7.1.2 485 5/25/2023
7.1.1 862 4/3/2023
7.1.1-rc.2 74 3/30/2023
7.1.1-rc.1 72 3/30/2023
7.1.0 794 2/28/2023
7.1.0-rc.1 86 2/20/2023
7.0.4-rc.5 87 2/23/2023
7.0.4-rc.4 85 2/23/2023
7.0.4-rc.3 85 2/23/2023
7.0.4-rc.2 82 2/22/2023
7.0.4-rc.1 91 2/16/2023
7.0.3 410 2/16/2023
7.0.2 258 2/9/2023
7.0.2-rc.1 100 2/2/2023
7.0.1 592 1/26/2023
7.0.0 471 1/24/2023
7.0.0-preview1 132 7/18/2022
7.0.0-beta.9 97 1/24/2023
7.0.0-beta.8 88 1/23/2023
7.0.0-beta.7 90 1/23/2023
7.0.0-beta.6 90 1/23/2023
7.0.0-beta.5 98 1/23/2023
7.0.0-beta.4 96 1/19/2023
7.0.0-beta.3 90 1/17/2023
7.0.0-beta.2 95 1/11/2023
7.0.0-beta.1 81 11/24/2022
6.2.2 1,247 9/20/2022
6.2.2-rc.1 107 9/19/2022
6.2.1 1,916 5/4/2022
6.2.0 453 4/21/2022
6.2.0-rc.2 122 4/21/2022
6.2.0-rc.1 120 4/20/2022
6.1.1 946 3/1/2022
6.1.0 605 2/10/2022
6.1.0-rc.3 118 2/10/2022
6.1.0-rc.2 112 2/10/2022
6.1.0-rc.1 117 2/9/2022
6.0.3 1,400 1/18/2022
6.0.2 752 1/10/2022
6.0.1 301 12/16/2021
6.0.0 629 12/13/2021
6.0.0-rc.6 143 12/6/2021
6.0.0-rc.5 339 12/6/2021
6.0.0-rc.4 477 12/6/2021
6.0.0-rc.3 355 12/6/2021
6.0.0-rc.2 333 12/6/2021
6.0.0-rc.1 630 11/15/2021
5.4.0 647 10/13/2021
5.3.0 330 9/23/2021
5.3.0-rc.1 334 9/17/2021
5.2.0 2,608 5/20/2021
5.2.0-rcjh.6 186 5/19/2021
5.2.0-rcjh.5 141 5/19/2021
5.2.0-rcjh.4 166 5/19/2021
5.2.0-rcjh.3 140 5/19/2021
5.2.0-rcjh.2 132 4/12/2021
5.2.0-rcjh.1 135 4/12/2021
5.1.3 339 5/19/2021
5.1.2 623 3/26/2021
5.1.1 958 1/13/2021
5.1.0 1,927 12/16/2020
5.0.0 664 11/17/2020
5.0.0-rc.1 241 10/15/2020
2.0.6 1,433 10/8/2020
2.0.5 1,186 8/19/2020
2.0.4 2,401 7/10/2020
2.0.3 464 7/10/2020
2.0.2 499 7/9/2020
2.0.1 496 7/9/2020
2.0.0 489 6/17/2020
1.0.0 485 6/15/2020