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
<PackageReference Include="OSKHelpers.Mail" Version="1.2.3" />
<PackageVersion Include="OSKHelpers.Mail" Version="1.2.3" />
<PackageReference Include="OSKHelpers.Mail" />
paket add OSKHelpers.Mail --version 1.2.3
#r "nuget: OSKHelpers.Mail, 1.2.3"
#:package OSKHelpers.Mail@1.2.3
#addin nuget:?package=OSKHelpers.Mail&version=1.2.3
#tool nuget:?package=OSKHelpers.Mail&version=1.2.3
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 | 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. 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. |
-
.NETStandard 2.0
- MailKit (>= 4.16.0)
- OSKHelpers (>= 1.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated reference to latest (4.16.0) MailKit NuGet package.