OSKHelpers.Mail 1.2.3

Prefix Reserved
dotnet add package OSKHelpers.Mail --version 1.2.3
                    
NuGet\Install-Package OSKHelpers.Mail -Version 1.2.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="OSKHelpers.Mail" Version="1.2.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OSKHelpers.Mail" Version="1.2.3" />
                    
Directory.Packages.props
<PackageReference Include="OSKHelpers.Mail" />
                    
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 OSKHelpers.Mail --version 1.2.3
                    
#r "nuget: OSKHelpers.Mail, 1.2.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.
#:package OSKHelpers.Mail@1.2.3
                    
#: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=OSKHelpers.Mail&version=1.2.3
                    
Install as a Cake Addin
#tool nuget:?package=OSKHelpers.Mail&version=1.2.3
                    
Install as a Cake Tool

OSKHelpers.Mail

OSKHelpers.Mail is a lightweight wrapper around MailKit that simplifies sending and receiving e-mails from .NET Standard 2.0 applications.
It integrates natively with OSKHelpers (logging via SimpleLog, configuration via IniFileHelper) and provides a template-based message composition system.


Namespaces & Classes

OSKHelpers.Mail

Class Description
MailWorker Central static class for all mail operations. Manages SMTP and IMAP connection parameters, composes messages from plain text or template files, and sends them asynchronously via MailKit.
SMTP configuration

MailWorker exposes a set of static properties for SMTP:

Property Description
SmtpServer Address of the SMTP server.
SmtpPort SMTP server port.
SmtpSSL Enables SSL/TLS for the SMTP connection.
SmtpUsername / SmtpPassword Credentials for SMTP authentication (authentication is disabled when both are empty).
SmtpFrom Optional default sender address used when no from is specified in a send call.
SmtpAuthEnabled true when both username and password are set.
SmtpAuthConfigError true when only one of the two credentials is set (configuration error).

Configuration can be loaded from an INI file via SetupSmtp(IniFileHelper) or set programmatically via SetupSmtp(server, port, ssl, username, password, from).

IMAP configuration
Property Description
ImapServer Address of the IMAP server.
ImapPort IMAP server port.
ImapSSL Enables SSL/TLS for the IMAP connection.
ImapUsername / ImapPassword Credentials for IMAP authentication.
ImapAuthConfigError true when username or password is missing.

Configuration is loaded from an INI file via SetupImap(IniFileHelper) or set programmatically via SetupImap(server, port, ssl, username, password).

Sending messages
Method Description
SendAsync(recipients, subject, body, attachments) Sends an HTML message to one or more recipients with optional stream-based attachments.
SendFromFileAsync(recipients, templateFile, tags, attachments) Composes the message body from a template text file, replacing {TAG} placeholders with the provided values and extracting the subject from an @Subject: line. Supports conditional blocks and comment lines (#).
Diagnostics
Method Description
DumpStmpParameters Prints or logs the current SMTP settings (password is masked).
DumpImapParameters Prints or logs the current IMAP settings (password is masked).
SetLogLevel Sets the SimpleLog log level for the library.

INI configuration template

The package ships a ready-to-use INI template (SettingsTemplate.Mail.ini) that documents all supported keys for SMTP and IMAP. Copy it to your project and rename it Settings.ini to get started.


Mail templates

The package includes a MailTemplates/ folder with:

File Description
0Index.txt Index and usage notes for the template system.
Credentials.txt Example template for credential-notification e-mails.

Dependencies

Package Purpose
MailKit SMTP/IMAP transport layer.
OSKHelpers Logging (SimpleLog) and INI configuration (IniFileHelper).
System.Text.Json JSON serialisation.

License

BSD 3-Clause — see the LICENSE file.

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.2.3 97 4/22/2026
1.2.2 103 4/11/2026
1.2.1 104 4/9/2026
1.2.0 97 4/9/2026

Updated reference to latest (4.16.0) MailKit NuGet package.