SocketLabs.EmailDelivery 1.4.2

.NET 5.0 .NET Standard 2.0 .NET Framework 4.8
dotnet add package SocketLabs.EmailDelivery --version 1.4.2
NuGet\Install-Package SocketLabs.EmailDelivery -Version 1.4.2
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="SocketLabs.EmailDelivery" Version="1.4.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SocketLabs.EmailDelivery --version 1.4.2
#r "nuget: SocketLabs.EmailDelivery, 1.4.2"
#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 SocketLabs.EmailDelivery as a Cake Addin
#addin nuget:?package=SocketLabs.EmailDelivery&version=1.4.2

// Install SocketLabs.EmailDelivery as a Cake Tool
#tool nuget:?package=SocketLabs.EmailDelivery&version=1.4.2


Twitter Follow MIT licensed PRs Welcome GitHub contributors alternate text is missing from this package README image

The SocketLabs Email Delivery C# library allows you to easily send email messages via the SocketLabs Injection API. The library makes it easy to build and send any type of message supported by the API, from a simple message to a single recipient all the way to a complex bulk message sent to a group of recipients with unique merge data per recipient.

Table of Contents

Prerequisites and Installation


  • A supported .NET version
    • .NET version 4.5 or higher
    • .NET Core 1.0 or higher
    • .NET Standard 1.3 or higher
  • A SocketLabs account. If you don't have one yet, you can sign up for a free account to get started.


For most uses we recommend installing the SocketLabs.EmailDelivery package via Nuget. If you have the Nuget Package Manager installed already, you can add the latest version of the package with the following command:

PM> Install-Package SocketLabs.EmailDelivery

Adding a Package Reference to your project:

<PackageReference Include="SocketLabs.EmailDelivery" Version="1.4.2" />

.NET CLI users can also use the following command:

> dotnet add package SocketLabs.EmailDelivery

Alternately, you can simply clone this repository directly to include the source code in your project.

Note for Visual Studio 2012 and earlier users: Due to an issue with dependency requirements, the package manager in VS2012 and earlier does not support installation of the current nuget package. In order to install the package directly, all you need to do is download the latest release binaries located at Once you download the zip file, extract the files, and add the dll's from the lib\net45 directory as references. You can do this from the project menu by clicking "Add Reference" then going to the browse option and picking the dll's from there.

Getting Started

Obtaining your API Key and SocketLabs ServerId number

In order to get started, you'll need to enable the Injection API feature in the SocketLabs Control Panel. Once logged in, navigate to your SocketLabs server's dashboard (if you only have one server on your account you'll be taken here immediately after logging in). Make note of your 4 or 5 digit ServerId number, as you'll need this along with your API key in order to use the Injection API.

To enable the Injection API, click on the "For Developers" dropdown on the top-level navigation, then choose the "Configure HTTP Injection API" option. Once here, you can enable the feature by choosing the "Enabled" option in the dropdown. Enabling the feature will also generate your API key, which you'll need (along with your ServerId) to start using the API. Be sure to click the "Update" button to save your changes once you are finished.

Quick Send

The QuickSend() method is a static method that allows you to quickly and easily send a message to a single recipient without the need for any setup code or even instantiating a client!

using SocketLabs.InjectionApi;

                000001, //Your SocketLabs ServerId
                "YOUR-API-KEY", //Your Injection API Key
                "", //The To address for your message
                "", //The From address for your message
                "Lorem Ipsum", //The Subject line for your message
                "<html>Lorem Ipsum</html>", //The HTML content for your message
                "Lorem Ipsum" //The plaintext content for your message

Basic Message

A basic message is an email message like you'd send from a personal email client such as Outlook. A basic message can have many recipients, including multiple To addresses, CC addresses, and even BCC addresses. You can also send a file attachment in a basic message.

using SocketLabs.InjectionApi;
using SocketLabs.InjectionApi.Message;

var client = new SocketLabsClient(000001, "YOUR-API-KEY"); //Your SocketLabs ServerId and Injection API key

var message = new BasicMessage();

message.Subject = "Sending A BasicMessage";
message.HtmlBody = "<html>This is the Html Body of my message.</html>";
message.PlainTextBody = "This is the Plain Text Body of my message.";

message.From.Email = "";

//A basic message supports up to 50 recipients and supports several different ways to add recipients
message.To.Add(""); //Add a To address by passing the email address
message.Cc.Add("", "Recipient #2"); //Add a CC address by passing the email address and a friendly name
message.Bcc.Add(new EmailAddress("")); //Add a BCC address by passing an EmailAddress object

var response = client.Send(message);

Bulk Message

A bulk message usually contains a single recipient per message and is generally used to send the same content to many recipients, optionally customizing the message via the use of MergeData. For more information about using Merge data, please see the Injection API documentation.

using SocketLabs.InjectionApi;
using SocketLabs.InjectionApi.Message;

var client = new SocketLabsClient(000001, "YOUR-API-KEY"); //Your SocketLabs ServerId and Injection API key

var message = new BulkMessage();

message.PlainTextBody = "This is the body of my message sent to %%Name%%";
message.HtmlBody = "<html>This is the HtmlBody of my message sent to %%Name%%</html>";
message.Subject = "Sending a test message";
message.From.Email = "";

var recipient1 = message.To.Add("");

var recipient2 = message.To.Add("");

var response = client.Send(message);

Managing API Keys

For ease of demonstration, many of our examples include the ServerId and API key directly in our code sample. Generally it is not considered a good practice to store sensitive information like this directly in your code. Depending on your project type, we recommend either storing your credentials in an app.config or a web.config file, or using Environment Variables. For more information please see:

Examples and Use Cases

In order to demonstrate the many possible use cases for the SDK, we've provided an assortment of code examples. These examples demonstrate many different features available to the Injection API and SDK, including using templates created in the SocketLabs Email Designer, custom email headers, sending attachments, sending content that is stored in an HTML file, advanced bulk merging, and even pulling recipients from a datasource.

Basic send from SocketLabs Template

This example demonstrates the sending of a piece of content that was created in the SocketLabs Email Designer. This is also known as the API Templates feature.

Basic send from HTML file

This example demonstrates how to read in your HTML content from an HTML file rather than passing in a string directly.

Basic send with file attachment

This example demonstrates how to add a file attachment to your message.

Basic send with embedded image

This example demonstrates how to embed an image in your message.

Basic send with specified character set

This example demonstrates sending with a specific character set.

Basic send with custom email headers

This example demonstrates how to add custom headers to your email message.

Basic send with a web proxy

This example demonstrates how to use a proxy with your HTTP client.

Basic send with retry enabled

This example demonstrates how to use the retry logic with your HTTP client.

Basic send complex example

This example demonstrates many features of the Basic Send, including adding multiple recipients, adding message and mailing id's, and adding an embedded image.

Basic send with Amp

This example demonstrates how to send a basic message with an AMP Html body. For more information about AMP please see AMP Project

Bulk send with multiple recipients

This example demonstrates how to send a bulk message to multiple recipients.

Bulk send with merge data

This example demonstrates how to send a bulk message to multiple recipients with unique merge data per recipient.

Bulk send with complex merge including attachments

This example demonstrates many features of the BulkMessage(), including adding multiple recipients, merge data, and adding an attachment.

Bulk send with recipients pulled from a datasource

This example uses a mock repository class to demonstrate how you would pull your recipients from a database and create a bulk mailing with merge data.

Bulk send with Ascii charset and special characters

This example demonstrates how to send a bulk message with a specified character set and special characters.

Bulk send with Amp

This example demonstrates how to send a bulk message with an AMP Html body. For more information about AMP please see AMP Project


See Release Notes


The SocketLabs.EmailDelivery library and all associated code, including any code samples, are MIT Licensed.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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. 
.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 is compatible.  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)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SocketLabs.EmailDelivery:

Package Downloads

Socketlabs Email delivery provider for Email.Net.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.2 3,317 5/24/2023
1.4.0 4,135 1/17/2023
1.3.4 13,525 8/8/2022
1.3.3 2,759 7/1/2022
1.2.3 14,232 4/21/2021
1.2.2 489 4/13/2021
1.2.1 585 3/19/2021
1.1.0 10,981 7/8/2020 10,605 8/22/2019 2,882 10/26/2018 765 10/12/2018 745 10/8/2018 593 10/5/2018