Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Send emails with .NET

Before you start, you'll need:

Prefer watching a video? Check out our video walkthrough below.

YouTube video player
  1. Install

    dotnet
    dotnet add package Resend
    Visual
    PM> Install-Package Resend
  2. Send 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 IResend instance:

    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 );
        }
    }
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu