Send emails with .NET
Prerequisites
Section titled “Prerequisites”Before you start, you'll need:
- A Resend API key
- A verified domain
Prefer watching a video? Check out our video walkthrough below.
Install
dotnet dotnet add package ResendVisual PM> Install-Package ResendSend emails using HTML
In the startup of your application, configure the DI container as follows:
C# 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
IResendinstance:C# using Resend; public class FeatureImplementation { private readonly IResend _resend; public FeatureImplementation( IResend resend ) { _resend = resend; } public Task Execute() { var message = new EmailMessage(); message.From = "Acme <onboarding@resend.dev>"; message.To.Add( "delivered@resend.dev" ); message.Subject = "hello world"; message.HtmlBody = "<strong>it works!</strong>"; await _resend.EmailSendAsync( message ); } }
Examples
Section titled “Examples”Basic Send
Basic email sending
Attachments
Send emails with file attachments
Templates
Send emails using Resend hosted templates
Scheduling
Schedule emails for future delivery
Audiences
Manage contacts and audiences
Domains
Create and manage sending domains
Inbound Webhooks
Receive and process inbound emails
Double Opt-in
Double opt-in subscription flow
Minimal API App
ASP.NET Minimal API application
MVC App
ASP.NET MVC application