Fusonic.Extensions.Email 9.3.1

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

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

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));

Razor Views (MVC)

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 Mediator-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));

Set a Subject

Per default the SubjectKey is "Subject" and it is being tried to resolve from the corresponding resource file. If you want to use a different key, you can set it in the EmailViewAttribute like this: [EmailView("Emails/Registration", SubjectKey = "RegistrationSubject")]. If no value could be found it will fallback to the the SubjectKey.

Razor Components (Blazor)

Create and send an email

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

  1. Add a new Component (.razor) in the directory Components/Emails/.
  2. Add a new ComponentModel in the same namespace as the business logic that needs to send the mail.
  3. Implement the IComponentModel<T> interface in the ComponentModel, where T is the type of the Component.
  4. Extend the EmailController with a new method to render the razor file and return the contents.
  5. To send the mail in the business logic use the Mediator-command SendEmail and supply it with the view model. SendEmail renders the mail based on the component model and the IComponentModel<T>.

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

Component locations

In contrast to the classic Razor Views, the Razor Components can be placed in any folder, even in a different assembly, as long as you can reference it in the IComponentModel<T>.

Set a Subject

Per default the SubjectKey is "Subject" and it is being tried to resolve from the corresponding resource file. If you want to use a different key, you can optionally implement the IProvideEmailSubject interface like this string IProvideEmailSubject.SubjectKey => "RegistrationSubject";. If no value could be found it will fallback to the the SubjectKey.

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.5.0 133 10/4/2024
9.4.0 110 9/23/2024
9.3.1 181 9/11/2024
9.3.0 103 9/11/2024
9.2.0 135 8/8/2024
9.2.0-rc.3 53 8/7/2024
9.2.0-rc.2 36 8/5/2024
9.2.0-rc.1 46 8/1/2024
9.1.0 71 7/29/2024
9.0.0 471 7/17/2024
9.0.0-preview.2 65 6/13/2024
9.0.0-preview.1 60 4/5/2024
8.1.3 205 3/27/2024
8.1.2 117 3/27/2024
8.1.1 111 3/1/2024
8.1.0 1,166 1/26/2024
8.0.1 179 12/18/2023
8.0.1-rc.2 82 12/7/2023
8.0.1-rc.1 73 12/6/2023
8.0.0 232 11/21/2023
8.0.0-preview1 113 10/4/2023
7.4.0 105 1/25/2024
7.3.0 198 10/11/2023
7.2.1-rc.1 92 8/28/2023
7.2.0 388 6/28/2023
7.2.0-alpha.1 84 6/27/2023
7.1.2 511 5/25/2023
7.1.1 893 4/3/2023
7.1.1-rc.2 86 3/30/2023
7.1.1-rc.1 81 3/30/2023
7.1.0 826 2/28/2023
7.1.0-rc.1 97 2/20/2023
7.0.4-rc.5 98 2/23/2023
7.0.4-rc.4 95 2/23/2023
7.0.4-rc.3 94 2/23/2023
7.0.4-rc.2 93 2/22/2023
7.0.4-rc.1 102 2/16/2023
7.0.3 421 2/16/2023
7.0.2 283 2/9/2023
7.0.2-rc.1 113 2/2/2023
7.0.1 606 1/26/2023
7.0.0 481 1/24/2023
7.0.0-preview1 155 7/18/2022
7.0.0-beta.9 108 1/24/2023
7.0.0-beta.8 99 1/23/2023
7.0.0-beta.7 102 1/23/2023
7.0.0-beta.6 101 1/23/2023
7.0.0-beta.5 109 1/23/2023
7.0.0-beta.4 106 1/19/2023
7.0.0-beta.3 98 1/17/2023
7.0.0-beta.2 104 1/11/2023
7.0.0-beta.1 93 11/24/2022
6.2.2 1,278 9/20/2022
6.2.2-rc.1 118 9/19/2022
6.2.1 1,944 5/4/2022
6.2.0 482 4/21/2022
6.2.0-rc.2 133 4/21/2022
6.2.0-rc.1 131 4/20/2022
6.1.1 973 3/1/2022
6.1.0 631 2/10/2022
6.1.0-rc.3 129 2/10/2022
6.1.0-rc.2 120 2/10/2022
6.1.0-rc.1 127 2/9/2022
6.0.3 1,421 1/18/2022
6.0.2 780 1/10/2022
6.0.1 330 12/16/2021
6.0.0 655 12/13/2021
6.0.0-rc.6 152 12/6/2021
6.0.0-rc.5 347 12/6/2021
6.0.0-rc.4 486 12/6/2021
6.0.0-rc.3 364 12/6/2021
6.0.0-rc.2 344 12/6/2021
6.0.0-rc.1 640 11/15/2021
5.4.0 672 10/13/2021
5.3.0 354 9/23/2021
5.3.0-rc.1 344 9/17/2021
5.2.0 2,633 5/20/2021
5.2.0-rcjh.6 197 5/19/2021
5.2.0-rcjh.5 151 5/19/2021
5.2.0-rcjh.4 176 5/19/2021
5.2.0-rcjh.3 149 5/19/2021
5.2.0-rcjh.2 141 4/12/2021
5.2.0-rcjh.1 143 4/12/2021
5.1.3 364 5/19/2021
5.1.2 645 3/26/2021
5.1.1 985 1/13/2021
5.1.0 1,956 12/16/2020
5.0.0 690 11/17/2020
5.0.0-rc.1 254 10/15/2020
2.0.6 1,461 10/8/2020
2.0.5 1,198 8/19/2020
2.0.4 2,430 7/10/2020
2.0.3 496 7/10/2020
2.0.2 526 7/9/2020
2.0.1 524 7/9/2020
2.0.0 513 6/17/2020
1.0.0 523 6/15/2020