{"id":19100169,"url":"https://github.com/socketlabs/socketlabs-csharp","last_synced_at":"2026-01-18T11:59:33.967Z","repository":{"id":41351829,"uuid":"151651870","full_name":"socketlabs/socketlabs-csharp","owner":"socketlabs","description":"SocketLabs Email Delivery .NET Client Library ","archived":false,"fork":false,"pushed_at":"2023-11-09T16:13:02.000Z","size":674,"stargazers_count":9,"open_issues_count":5,"forks_count":8,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-04-15T13:54:45.687Z","etag":null,"topics":["deliverability","dotnet","dotnet-core","email","socketlabs","transactional-email"],"latest_commit_sha":null,"homepage":"https://www.socketlabs.com","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/socketlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-10-05T00:20:08.000Z","updated_at":"2023-05-24T18:35:47.000Z","dependencies_parsed_at":"2023-10-11T20:56:17.980Z","dependency_job_id":"d6b18d44-3fd2-4b26-a07d-50927100b6f2","html_url":"https://github.com/socketlabs/socketlabs-csharp","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketlabs%2Fsocketlabs-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketlabs%2Fsocketlabs-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketlabs%2Fsocketlabs-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketlabs%2Fsocketlabs-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socketlabs","download_url":"https://codeload.github.com/socketlabs/socketlabs-csharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223783092,"owners_count":17201903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deliverability","dotnet","dotnet-core","email","socketlabs","transactional-email"],"created_at":"2024-11-09T03:52:32.342Z","updated_at":"2026-01-18T11:59:33.955Z","avatar_url":"https://github.com/socketlabs.png","language":"C#","funding_links":[],"categories":["dotnet"],"sub_categories":[],"readme":"[![SocketLabs](https://s3.amazonaws.com/static.socketlabs/logos/logo-dark-317x40.svg)](https://www.socketlabs.com/developers)  \n\n[![Twitter Follow](https://img.shields.io/twitter/follow/socketlabs.svg?style=social\u0026label=Follow)](https://twitter.com/socketlabs) \n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md) \n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/socketlabs/socketlabs-csharp/blob/master/CONTRIBUTING.md)\n[![GitHub contributors](https://img.shields.io/github/contributors/socketlabs/socketlabs-csharp.svg)](https://github.com/socketlabs/csharp-socketlabs/graphs/contributors)\n![](https://dev.azure.com/socketlabs/Public%20Projects/_apis/build/status/CSharp-CI?branchName=main)\n\n\nThe SocketLabs Email Delivery C# library allows you to easily send email messages via the [SocketLabs Injection API](https://www.socketlabs.com/docs/inject/).  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.\n\n# Table of Contents\n* [Prerequisites and Installation](#prerequisites-and-installation)\n* [Getting Started](#getting-started)\n* [Managing API Keys](#managing-api-keys)\n* [Examples and Use Cases](#examples-and-use-cases)\n* [Version](#version)\n* [License](#license)\n\n\n# Prerequisites and Installation\n## Prerequisites\n* A supported .NET version\n  * .NET Framework version 4.8 or higher\n  * .NET 8.0 or higher\n  * .NET Standard 2.0 or higher\n* A SocketLabs account. If you don't have one yet, you can [sign up for a free account](https://signup.socketlabs.com/step-1?plan=free) to get started.\n\n## Installation\nFor most uses we recommend installing the SocketLabs.EmailDelivery package via Nuget. If you have the [Nuget Package Manager](https://www.nuget.org/) installed already, you can add the latest version of the package with the following command:\n\n```\nPM\u003e Install-Package SocketLabs.EmailDelivery\n```\n\nAdding a Package Reference to your project:\n\n```\n\u003cPackageReference Include=\"SocketLabs.EmailDelivery\" Version=\"2.0.1\" /\u003e\n```\n\n.NET CLI users can also use the following command:\n\n```\n\u003e dotnet add package SocketLabs.EmailDelivery\n```\n\n\nAlternately, you can simply [clone this repository](https://github.com/socketlabs/socketlabs-csharp.git) directly to include the source code in your project.\n\n**Note for Visual Studio 2012 and earlier users**: Due to an issue with dependency requirements, the package manager in VS2012\nand earlier does not support installation of the current nuget package. In order to install the package directly, all you need to do\nis download the latest release binaries located at [https://github.com/socketlabs/socketlabs-csharp/releases/](https://github.com/socketlabs/socketlabs-csharp/releases/).\nOnce you download the zip file, extract the files, and add the dll's from ```the lib\\net45``` directory as references.\nYou can do this from the project menu by clicking \"Add Reference\" then going to the browse option and picking the dll's from there.\n\n# Getting Started\n## Obtaining your API Key and SocketLabs ServerId number\nIn order to get started, you'll need to enable the Injection API feature in the [SocketLabs Control Panel](https://cp.socketlabs.com).\nOnce 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).\nMake note of your 4 or 5 digit ServerId number, as you'll need this along with\nyour API key in order to use the Injection API.\n\nTo enable the Injection API, click on the \"For Developers\" dropdown on the top-level navigation, then choose the \"Configure HTTP Injection API\" option.\nOnce here, you can enable the feature by choosing the \"Enabled\" option in the\ndropdown. Enabling the feature will also generate your API key, which you'll\nneed (along with your ServerId) to start using the API. Be sure to click the\n\"Update\" button to save your changes once you are finished.\n\n## Quick Send\nThe `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!\n\n```C#\nusing SocketLabs.InjectionApi;\n\nSocketLabsClient.QuickSend(\n                000001, //Your SocketLabs ServerId\n                \"YOUR-API-KEY\", //Your Injection API Key\n                \"recipient@example.com\", //The To address for your message\n                \"from@example.com\", //The From address for your message\n                \"Lorem Ipsum\", //The Subject line for your message\n                \"\u003chtml\u003eLorem Ipsum\u003c/html\u003e\", //The HTML content for your message\n                \"Lorem Ipsum\" //The plaintext content for your message\n            );\n```\n\n## Basic Message\nA basic message is an email message like you'd send from a personal email client such as Outlook.\nA basic message can have many recipients, including multiple To addresses, CC addresses, and even BCC addresses.\nYou can also send a file attachment in a basic message.\n\n```C#\nusing SocketLabs.InjectionApi;\nusing SocketLabs.InjectionApi.Message;\n\nvar client = new SocketLabsClient(000001, \"YOUR-API-KEY\"); //Your SocketLabs ServerId and Injection API key\n\nvar message = new BasicMessage();\n\nmessage.Subject = \"Sending A BasicMessage\";\nmessage.HtmlBody = \"\u003chtml\u003eThis is the Html Body of my message.\u003c/html\u003e\";\nmessage.PlainTextBody = \"This is the Plain Text Body of my message.\";\n\nmessage.From.Email = \"from@example.com\";\n\n//A basic message supports up to 50 recipients and supports several different ways to add recipients\nmessage.To.Add(\"recipient1@example.com\"); //Add a To address by passing the email address\nmessage.Cc.Add(\"recipient2@example.com\", \"Recipient #2\"); //Add a CC address by passing the email address and a friendly name\nmessage.Bcc.Add(new EmailAddress(\"recipient3@example.com\")); //Add a BCC address by passing an EmailAddress object\n\nvar response = client.Send(message);\n```\n\n## Bulk Message\nA bulk message usually contains a single recipient per message\nand is generally used to send the same content to many recipients,\noptionally customizing the message via the use of MergeData.\nFor more information about using Merge data, please see the [Injection API documentation](https://www.socketlabs.com/docs/inject/).\n```C#\nusing SocketLabs.InjectionApi;\nusing SocketLabs.InjectionApi.Message;\n\nvar client = new SocketLabsClient(000001, \"YOUR-API-KEY\"); //Your SocketLabs ServerId and Injection API key\n\nvar message = new BulkMessage();\n\nmessage.PlainTextBody = \"This is the body of my message sent to %%Name%%\";\nmessage.HtmlBody = \"\u003chtml\u003eThis is the HtmlBody of my message sent to %%Name%%\u003c/html\u003e\";\nmessage.Subject = \"Sending a test message\";\nmessage.From.Email = \"from@example.com\";\n\nvar recipient1 = message.To.Add(\"recipient1@example.com\");\nrecipient1.MergeData.Add(\"Name\",\"Recipient1\");\n\nvar recipient2 = message.To.Add(\"recipient2@example.com\");\nrecipient2.MergeData.Add(\"Name\",\"Recipient2\");\n\nvar response = client.Send(message);\n```\n\n## Managing API Keys\nFor ease of demonstration, many of our examples include the ServerId and API\nkey directly in our code sample. Generally it is not considered a good practice\nto store sensitive information like this directly in your code. Depending on\nyour project type, we recommend either storing your credentials in an `app.config` or a `web.config` file, or using Environment Variables. For more\ninformation please see:\n* [Using web.config](https://docs.microsoft.com/en-us/aspnet/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure)\n* [Using Environment Variables](https://docs.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariable)\n\n## Examples and Use Cases\nIn order to demonstrate the many possible use cases for the SDK, we've provided\nan assortment of code examples. These examples demonstrate many different\nfeatures available to the Injection API and SDK, including using templates\ncreated in the [SocketLabs Email Designer](https://www.socketlabs.com/blog/introducing-new-email-designer/), custom email headers, sending\nattachments, sending content that is stored in an HTML file, advanced bulk\nmerging, and even pulling recipients from a datasource.\n\n### [Basic send from SocketLabs Template](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithApiTemplate.cs)\nThis example demonstrates the sending of a piece of content that was created in the\nSocketLabs Email Designer. This is also known as the [API Templates](https://www.socketlabs.com/blog/introducing-api-templates/) feature.\n\n### [Basic send from HTML file](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendFromHtmlFile.cs)\nThis example demonstrates how to read in your HTML content from an HTML file\nrather than passing in a string directly.\n\n### [Basic send with file attachment](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithAttachment.cs)\nThis example demonstrates how to add a file attachment to your message.\n\n### [Basic send with embedded image](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithEmbeddedImage.cs)\nThis example demonstrates how to embed an image in your message.\n\n### [Basic send with specified character set](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithAsciiCharset.cs)\nThis example demonstrates sending with a specific character set.\n\n### [Basic send with custom email headers](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithCustomHeaders.cs)\nThis example demonstrates how to add custom headers to your email message.\n\n### [Basic send with a web proxy](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithProxy.cs)\nThis example demonstrates how to use a proxy with your HTTP client.\n\n### [Basic send with retry enabled](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithRetry.cs)\nThis example demonstrates how to use the retry logic with your HTTP client.\n\n### [Basic send complex example](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicComplexExample.cs)\nThis example demonstrates many features of the Basic Send, including adding multiple recipients, adding message and mailing id's, and adding an embedded image.\n\n### [Basic send with Amp ](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Basic/BasicSendWithApiTemplate.cs)\nThis example demonstrates how to send a basic message with an AMP Html body.\nFor more information about AMP please see [AMP Project](https://amp.dev/documentation/)\n\n### [Bulk send with multiple recipients](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Bulk/BulkSend.cs)\nThis example demonstrates how to send a bulk message to multiple recipients.\n\n### [Bulk send with merge data](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Bulk/BulkSendWithMergeData.cs)\nThis example demonstrates how to send a bulk message to multiple recipients with\nunique merge data per recipient.\n\n### [Bulk send with complex merge including attachments](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Bulk/BulkSendComplexExample.cs)\nThis example demonstrates many features of the `BulkMessage()`, including\nadding multiple recipients, merge data, and adding an attachment.\n\n### [Bulk send with recipients pulled from a datasource](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Bulk/BulkSendFromDataSourceWithMerge.cs)\nThis example uses a mock repository class to demonstrate how you would pull\nyour recipients from a database and create a bulk mailing with merge data.\n\n### [Bulk send with Ascii charset and special characters](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Bulk/BulkSendWithAsciiCharsetMergeData.cs)\nThis example demonstrates how to send a bulk message with a specified character\nset and special characters.\n\n### [Bulk send with Amp ](https://github.com/socketlabs/socketlabs-csharp/blob/master/Example%20Projects/dotNetCoreExample/Examples/Bulk/BulkSendWithAmpBody.cs)\nThis example demonstrates how to send a bulk message with an AMP Html body.\nFor more information about AMP please see [AMP Project](https://amp.dev/documentation/)\n\n# Version\nSee [Release Notes](./docs/release-notes/latest.md)\n\n# License\nThe SocketLabs.EmailDelivery library and all associated code, including any code samples, are [MIT Licensed](https://github.com/socketlabs/socketlabs-csharp/blob/master/LICENSE.MD).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketlabs%2Fsocketlabs-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketlabs%2Fsocketlabs-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketlabs%2Fsocketlabs-csharp/lists"}