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: 3 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 (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-11T16:03:29.000Z (4 months ago)
- Last Synced: 2025-06-23T17:47:39.357Z (3 months ago)
- Topics: csharp, dotnet, email, resend, resend-net
- Language: C#
- Homepage:
- Size: 296 KB
- Stars: 61
- Watchers: 2
- Forks: 2
- Open Issues: 10
-
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 languageSetup
--------------------------------------------------------------------------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 = "you@example.com";
message.To.Add( "user@gmail.com" );
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 = "you@example.com";
message.To.Add( "user@gmail.com" );
message.Subject = "hello world";
message.HtmlBody = "it works!";await _resend.EmailSendAsync( message );
}
}
```License
--------------------------------------------------------------------------MIT License