Encamina.Enmarcha.Email.MailKit
8.1.6-preview-05
See the version list below for details.
dotnet add package Encamina.Enmarcha.Email.MailKit --version 8.1.6-preview-05
NuGet\Install-Package Encamina.Enmarcha.Email.MailKit -Version 8.1.6-preview-05
<PackageReference Include="Encamina.Enmarcha.Email.MailKit" Version="8.1.6-preview-05" />
paket add Encamina.Enmarcha.Email.MailKit --version 8.1.6-preview-05
#r "nuget: Encamina.Enmarcha.Email.MailKit, 8.1.6-preview-05"
// Install Encamina.Enmarcha.Email.MailKit as a Cake Addin #addin nuget:?package=Encamina.Enmarcha.Email.MailKit&version=8.1.6-preview-05&prerelease // Install Encamina.Enmarcha.Email.MailKit as a Cake Tool #tool nuget:?package=Encamina.Enmarcha.Email.MailKit&version=8.1.6-preview-05&prerelease
Email - MailKit
MailKit is a project designed to simplify the configuration and sending of emails. The most typical use case is configuring your SMTP account and sending an email with attachments, subject, and more.
Setup
Nuget package
First, install NuGet. Then, install Encamina.Enmarcha.Email.MailKit from the package manager console:
PM> Install-Package Encamina.Enmarcha.Email.MailKit
.NET CLI:
Install .NET CLI. Next, install Encamina.Enmarcha.Email.MailKit from the .NET CLI:
dotnet add package Encamina.Enmarcha.Email.MailKit
How to use
First, you need to add the SmtpClientOptions to your project configuration. You can achieve this by using any configuration provider. The followng code is an example of how the settings should look like using the appsettings.json
file:
{
// ...
"SmtpClientOptions": {
"User": "<SMPT_USER>", // User credential required to connect to the SMTP service
"Password": "<SMPT_PASSWORD>", // Password credential required to connect to the SMTP service
"Port": "<SMPT_PORT>", // Port for the SMTP service
"Host": "<SMPT_HOST>" // Host name of the SMTP service.
}
// ...
}
Next, in Program.cs
or a similar entry point file in your project, add the following code.
// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
// ...
});
// ...
// Or others configuration providers...
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
builder.Services.AddMailKitEmailProvider(builder.Configuration, serviceLifetime: ServiceLifetime.Singleton);
There are also other overloads of AddMailKitEmailProvider
on which you can directly specify the SMTP data.
// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
// ...
});
// ...
builder.Services.AddMailKitEmailProvider(options =>
{
options.User = "<SMPT_USER>"; // User credential required to connect to the SMTP service
options.Password = "<SMPT_PASSWORD>"; // Password credential required to connect to the SMTP service
options.Port = "<SMPT_PORT>"; // Port for the SMTP service
options.Host = "<SMPT_HOST>"; // Host name of the SMTP service.
});
With this, we can resolve the IEmailProvider
interface and be able to send an email.
public class MyClass
{
private readonly IEmailProvider emailProvider;
public MyClass(IEmailProvider emailProvider)
{
this.emailProvider = emailProvider;
}
public async Task SendTestEmailAsync(CancellationToken cancellationToken)
{
await emailProvider.BeginSendEmail()
.SetDefaultSender()
.SetSubject("Test email Subject")
.SetBody("Test body subject")
.AddRecipient("contoso@email.com")
.AddAttachment("testFile.txt", Encoding.UTF8.GetBytes("Attachment File"))
.SendAsync(cancellationToken);
}
}
Product | Versions 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. |
.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. |
-
.NETStandard 2.1
- CommunityToolkit.Diagnostics (>= 8.2.2)
- Encamina.Enmarcha.Core (>= 8.1.6-preview-05)
- Encamina.Enmarcha.DependencyInjection (>= 8.1.6-preview-05)
- Encamina.Enmarcha.Email.Abstractions (>= 8.1.6-preview-05)
- Encamina.Enmarcha.Entities (>= 8.1.6-preview-05)
- MailKit (>= 4.5.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
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 |
---|---|---|
8.2.0 | 127 | 10/22/2024 |
8.2.0-preview-01-m01 | 91 | 9/17/2024 |
8.1.9-preview-03 | 60 | 11/19/2024 |
8.1.9-preview-02 | 64 | 10/22/2024 |
8.1.9-preview-01 | 126 | 10/4/2024 |
8.1.8 | 138 | 9/23/2024 |
8.1.8-preview-07 | 67 | 9/12/2024 |
8.1.8-preview-06 | 143 | 9/11/2024 |
8.1.8-preview-05 | 90 | 9/10/2024 |
8.1.8-preview-04 | 197 | 8/16/2024 |
8.1.8-preview-03 | 124 | 8/13/2024 |
8.1.8-preview-02 | 102 | 8/13/2024 |
8.1.8-preview-01 | 105 | 8/12/2024 |
8.1.7 | 105 | 8/7/2024 |
8.1.7-preview-09 | 102 | 7/3/2024 |
8.1.7-preview-08 | 100 | 7/2/2024 |
8.1.7-preview-07 | 69 | 6/10/2024 |
8.1.7-preview-06 | 89 | 6/10/2024 |
8.1.7-preview-05 | 90 | 6/6/2024 |
8.1.7-preview-04 | 92 | 6/6/2024 |
8.1.7-preview-03 | 102 | 5/24/2024 |
8.1.7-preview-02 | 94 | 5/10/2024 |
8.1.7-preview-01 | 105 | 5/8/2024 |
8.1.6 | 1,218 | 5/7/2024 |
8.1.6-preview-08 | 71 | 5/2/2024 |
8.1.6-preview-07 | 101 | 4/29/2024 |
8.1.6-preview-06 | 97 | 4/26/2024 |
8.1.6-preview-05 | 101 | 4/24/2024 |
8.1.6-preview-04 | 101 | 4/22/2024 |
8.1.6-preview-03 | 94 | 4/22/2024 |
8.1.6-preview-02 | 81 | 4/17/2024 |
8.1.6-preview-01 | 175 | 4/15/2024 |
8.1.5 | 105 | 4/15/2024 |
8.1.5-preview-15 | 84 | 4/10/2024 |
8.1.5-preview-14 | 107 | 3/20/2024 |
8.1.5-preview-13 | 83 | 3/18/2024 |
8.1.5-preview-12 | 109 | 3/13/2024 |
8.1.5-preview-11 | 93 | 3/13/2024 |
8.1.5-preview-10 | 94 | 3/13/2024 |
8.1.5-preview-09 | 92 | 3/12/2024 |
8.1.5-preview-08 | 75 | 3/12/2024 |
8.1.5-preview-07 | 91 | 3/8/2024 |
8.1.5-preview-06 | 65 | 3/8/2024 |
8.1.5-preview-05 | 93 | 3/7/2024 |
8.1.5-preview-04 | 104 | 3/7/2024 |
8.1.5-preview-03 | 99 | 3/7/2024 |
8.1.5-preview-02 | 97 | 2/28/2024 |
8.1.5-preview-01 | 85 | 2/19/2024 |
8.1.4 | 165 | 2/15/2024 |
8.1.3 | 119 | 2/13/2024 |
8.1.3-preview-07 | 70 | 2/13/2024 |
8.1.3-preview-06 | 90 | 2/12/2024 |
8.1.3-preview-05 | 102 | 2/9/2024 |
8.1.3-preview-04 | 90 | 2/8/2024 |
8.1.3-preview-03 | 97 | 2/7/2024 |
8.1.3-preview-02 | 82 | 2/2/2024 |
8.1.3-preview-01 | 81 | 2/2/2024 |
8.1.2 | 122 | 2/1/2024 |
8.1.2-preview-9 | 104 | 1/22/2024 |
8.1.2-preview-8 | 84 | 1/19/2024 |
8.1.2-preview-7 | 88 | 1/19/2024 |
8.1.2-preview-6 | 85 | 1/19/2024 |
8.1.2-preview-5 | 97 | 1/19/2024 |
8.1.2-preview-4 | 94 | 1/19/2024 |
8.1.2-preview-3 | 82 | 1/18/2024 |
8.1.2-preview-2 | 93 | 1/18/2024 |
8.1.2-preview-16 | 91 | 1/31/2024 |
8.1.2-preview-15 | 97 | 1/31/2024 |
8.1.2-preview-14 | 90 | 1/25/2024 |
8.1.2-preview-13 | 92 | 1/25/2024 |
8.1.2-preview-12 | 93 | 1/23/2024 |
8.1.2-preview-11 | 72 | 1/23/2024 |
8.1.2-preview-10 | 89 | 1/22/2024 |
8.1.2-preview-1 | 88 | 1/18/2024 |
8.1.1 | 124 | 1/18/2024 |
8.1.0 | 102 | 1/18/2024 |
8.0.3 | 163 | 12/29/2023 |
8.0.1 | 126 | 12/14/2023 |
8.0.0 | 133 | 12/7/2023 |
6.0.4.3 | 114 | 12/29/2023 |
6.0.4.2 | 113 | 12/20/2023 |
6.0.4.1 | 185 | 12/19/2023 |
6.0.4 | 138 | 12/4/2023 |
6.0.3.20 | 117 | 11/27/2023 |
6.0.3.19 | 124 | 11/22/2023 |