Emailit.Client 1.0.1

Suggested Alternatives

Emailit.Client.v2

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

Emailit.Client

This is an unofficial open-source HTTP client designed for use with the Emailit API.

The client is based on Flurl.

Basic usage

1. Initialize the Client

You can simply instantiate EmailitClient using the default constructor:

var client = new EmailitClient();

However, in order to use EmailitClient, you will need your Emailit API Key anyway. You can provide it in one of four ways:

  • Via the constructor:
var client = new EmailitClient("youApiKey");
  • Via an EmailitConfiguration object:
var config = new EmailitConfiguration
{
	ApiKey = "yourApiKey",
};

var client = new EmailitClient(config);
  • Via a configuration action:
var client = new EmailitClient(config => {
	config.ApiKey = "yourApiKey"
})
  • After initialization using the UseApiKey() method:
var client = new EmailitClient();

client.UseApiKey("yourApiKey");

2. Creating Emailit Messages

Before sending an email using EmailitClient, you need to create an email message. Emailit messages are represented by the EmailitMessage model. You can create one in two ways:

  • Using an EmailitMessage literal:
var message = new EmailitMessage
{
	From = some@email.com",
	To = "recipient@email.com",
	Subject = "Some subject",
	Text = "Some text",
}
  • Using an EmailitMessageBuilder
var message = new EmailitMessageBuilder()
	.From("some@email.com")
	.To("recipient@email.com")
	.ReplyTo("some.other@email.com")
	.Subject("Some subject")
	.WithHtmlContent("<h1>Some HTML</h1>")
	.Message;

NOTE: It is recommended to build EmailitMessage instances using EmailitMessageBuilder, as it provides some basic null checks and validation. If you use EmailitMessage directly, you must handle validation yourself..

3. Support for Email Attachments

EmailitMessage provides support for email attachments, represented by EmailitAttachment object:

  • You can initialize it via the constructor:
var attachment = new EmailitAttachment(
	"someattachment.pdf",
	"<based-64 array of bytes>"
);
  • Or via object literal:
var attachment = new EmailitAttachment
{
	FileName: "somefile.pdf",
	Content: "<based-64 array of bytes>"
};
  • You can also create it directly from a byte array:
var attachment = EmailitAttachment.FromByteArray(<array of bytes here>, "filename.png");

Once created, attachments can be easily added to an EmailitMessage:

var attachment = new EmailitAttachment(); 
var message = new EmailitMessage();

message.AddAttachment(attachment);

Attachment can be also added as array of bytes, directly to EmailitMessage:

message.AddAttachment(<array of bytes>, "filename.png");

4. Sending e-mails

Once your EmailitMessage is ready, you can send it using:

  • EmailitClient:
var client = new EmailitClient("yourApiKey");

var message = new EmailitMessageBuilder()
	.From("some@email.com")
	.To("recipient@email.com")
	.ReplyTo("some.other@email.com")
	.Subject("Some subject")
	.WithTextContent("Some text")
	.Message;

await client.SendEmailAsync(message);
  • Directly from EmailitMessage (using an extension method):
var message = new EmailitMessageBuilder()
	.From("some@email.com")
	.To("recipient@email.com")
	.ReplyTo("some.other@email.com")
	.Subject("Some subject")
	.WithTextContent("Some text")
	.Message;

await message.SendAsync("yourApiKey");

5. Overriding default settings

The default EmailitClient settings are defined in the protected virtual DefaultBaseUrl property, which:

  • Provides default JsonSerializerOptions for the System.Text.Json serializer
  • Verifies that the ApiKey is supplied (throws if not)
  • Supplies the API Call with the provided ApiKey
  • Builds a basic Url object (a Flurl object) using default _baseUrl and _version

To override the default behavior, simply create a custom class that derives from 'EmailitClient'. You can then redefine the 'DefaultBaseUrl' behavior as needed.

What is not covered

EmailitClient covers three crutial Emailit functionalities:

  • Managing Credentials
  • Managing Sending Domains
  • Sending Emails

It does not cover managing audiences, contacts, events and campaigns. Feel free to contribute and help expand this functionality!

Roadmap

In the nearest future, I'd like to:

  • Create a separate package that provides FluentValidation for Emailit objects
  • Implement missing EmailitClient methods and models (see above)
  • Enhance support for Dependency Injection (currently uses a simple �clientless� pattern from Flurl)
  • Improve error handling, especially for HTTP status codes

Feel free to contribute!

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 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. 
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.0.1 227 10/5/2025 1.0.1 is deprecated because it is no longer maintained.
1.0.0 189 6/28/2025 1.0.0 is deprecated because it is no longer maintained.