https://github.com/resend/resend-dotnet
Resend's Official .NET SDK, written in C#
https://github.com/resend/resend-dotnet
csharp dotnet email resend resend-net
Last synced: 2 months ago
JSON representation
Resend's Official .NET SDK, written in C#
- Host: GitHub
- URL: https://github.com/resend/resend-dotnet
- Owner: resend
- License: mit
- Created: 2023-07-17T16:16:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-03-11T05:56:57.000Z (3 months ago)
- Last Synced: 2026-04-07T06:36:35.110Z (2 months ago)
- Topics: csharp, dotnet, email, resend, resend-net
- Language: C#
- Homepage:
- Size: 384 KB
- Stars: 67
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
Resend .NET SDK
==========================================================================
[](https://github.com/resend/resend-dotnet/actions)
[](https://www.nuget.org/packages/Resend/)
[](https://opensource.org/licenses/MIT)
.NET library for the Resend API.
Install
--------------------------------------------------------------------------
```
> dotnet add package Resend
```
Examples
--------------------------------------------------------------------------
Send email with:
* [ASP.NET - Minimal API](https://github.com/resend/resend-dotnet/tree/master/examples/WebMinimalApi) - Send email from an API
* [ASP.NET - Razor](https://github.com/resend/resend-dotnet/tree/master/examples/WebRazor) - Send email from a Razor web application
* [Console app](https://github.com/resend/resend-dotnet/tree/master/examples/ConsoleNoDi) - Send email from console app (without dependency injection)
* [Async - Hangfire](https://github.com/resend/resend-dotnet/tree/master/examples/AsyncHangfire) - Send email as a background job using [Hangfire](https://www.hangfire.io/)
* [Async - Temporal](https://github.com/resend/resend-dotnet/tree/master/examples/AsyncTemporal) - Send email in durable workflow using [Temporal](https://temporal.io/)
* [Render - Razor](https://github.com/resend/resend-dotnet/tree/master/examples/RenderRazor) - Render an HTML body using Razor views
* [Render - Liquid](https://github.com/resend/resend-dotnet/tree/master/examples/RenderLiquid) - Render an HTML body using [Fluid](https://github.com/sebastienros/fluid), a [Liquid](https://shopify.github.io/liquid/) template language
Setup
--------------------------------------------------------------------------
First, you need to get an API key, which is available in the
[Resend Dashboard](https://resend.com/).
In the startup of your application, configure the DI container as follows:
```csharp
using Resend;
builder.Services.AddOptions();
builder.Services.AddHttpClient();
builder.Services.Configure( o =>
{
o.ApiToken = Environment.GetEnvironmentVariable( "RESEND_APITOKEN" )!;
} );
builder.Services.AddTransient()
```
You can then use the injected `IResend` instance to send emails.
Usage
--------------------------------------------------------------------------
Send your first email:
```csharp
using Resend;
public class FeatureImplementation
{
private readonly IResend _resend;
public FeatureImplementation( IResend resend )
{
_resend = resend;
}
public async Task Execute()
{
var message = new EmailMessage();
message.From = "onboarding@resend.dev";
message.To.Add( "delivered@resend.dev" );
message.Subject = "hello world";
message.TextBody = "it works!";
await _resend.EmailSendAsync( message );
}
}
```
Send email using HTML
--------------------------------------------------------------------------
Send an email custom HTML content:
```csharp
using Resend;
public class FeatureImplementation
{
private readonly IResend _resend;
public FeatureImplementation( IResend resend )
{
_resend = resend;
}
public async Task Execute()
{
var message = new EmailMessage();
message.From = "onboarding@resend.dev";
message.To.Add( "delivered@resend.dev" );
message.Subject = "hello world";
message.HtmlBody = "it works!";
await _resend.EmailSendAsync( message );
}
}
```
License
--------------------------------------------------------------------------
MIT License