.NET client for resend, an email API, written in C#.
The ResendClient
support the following objects (and methods):
- Email (Send, Batch, Retrieve)
- Domain (List, Add, Retrieve, Update, Verify, Delete)
- API key (List, Create, Delete)
- Audience (List, Add, Retrieve, Delete)
- Contact (List, Add, Retrieve, Update, Delete)
Package is published in the NuGet gallery.
From the command-line:
> dotnet add package Resend
From within Visual Studio using Package Manager Console:
PM> Install-Package Resend
In the startup of your application, configure the DI container as follows:
using Resend;
builder.Services.AddOptions();
builder.Services.AddHttpClient<ResendClient>();
builder.Services.Configure<ResendClientOptions>( o =>
{
o.ApiToken = Environment.GetEnvironmentVariable( "RESEND_APITOKEN" )!;
} );
builder.Services.AddTransient<IResend, ResendClient>()
Send an email using the injected IResend
instance:
using Resend;
public class FeatureImplementation
{
private readonly IResend _resend;
public FeatureImplementation( IResend resend )
{
_resend = resend;
}
public Task Execute()
{
var message = new EmailMessage();
message.From = "onboarding@resend.dev";
message.To.Add( "myapp@example.com" );
message.Subject = "Hello!";
message.HtmlBody = "<div><strong>Greetings<strong> ๐๐ป from .NET</div>";
await _resend.EmailSendAsync( message );
}
}
In addition to the .NET library, this repository also releases a cross platform command line interface program to invoke the API. This program is available as a .NET tool.
Command-line tool for Resend API
Usage: resend [command] [options]
Options:
--version Show version information.
-?|-h|--help Show help information.
Commands:
apikey API key management
audience Audience management
contact Contact management
domain Email (sender) domain management
email Send emails
webhook Webhook management
Run 'resend [command] -?|-h|--help' for more information about a command.
Each command has sub-commands: you can enumerate the sub-commands with
the --help
flag, eg resend email --help
.
- Check if there is API for webhooks (client side, as well as server side)
- Write documentation in the README.md
- Return ApiResponse (rather than T), for folks that prefer responses rather than exceptions
- Complete the API / object XML documentation
- Target multiple frameworks (.NET Standard, .NET 6) -- rather than .NET 7