# Send emails with .NET

## Prerequisites

Before you start, you'll need:

- A Resend [API key](/guides/get-started-create-an-api-key)
- A [verified domain](/guides/get-started-add-a-domain)

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

[YouTube video player](https://www.youtube.com/watch?v=HvFURxq1tgQ)

## Guide

:::::steps
::::step{title="Install"}
:::code-group
```bash dotnet CLI theme={"theme":{"light":"github-light","dark":"vesper"}}
dotnet add package Resend
```

```bash Visual Studio (Package Manager Console) theme={"theme":{"light":"github-light","dark":"vesper"}}
PM> Install-Package Resend
```
:::
::::

:::step{title="Send emails using HTML"}
In the startup of your application, configure the DI container as follows:

```csharp theme={"theme":{"light":"github-light","dark":"vesper"}}
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:

```csharp theme={"theme":{"light":"github-light","dark":"vesper"}}
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

::::card-grid
:::card{title="Basic Send" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/BasicSend.cs" icon="arrow-up-right-from-square"}
Basic email sending
:::

:::card{title="Attachments" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/WithAttachments.cs" icon="arrow-up-right-from-square"}
Send emails with file attachments
:::

:::card{title="Templates" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/WithTemplate.cs" icon="arrow-up-right-from-square"}
Send emails using Resend hosted templates
:::

:::card{title="Scheduling" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/ScheduledSend.cs" icon="arrow-up-right-from-square"}
Schedule emails for future delivery
:::

:::card{title="Audiences" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/Audiences.cs" icon="arrow-up-right-from-square"}
Manage contacts and audiences
:::

:::card{title="Domains" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/Domains.cs" icon="arrow-up-right-from-square"}
Create and manage sending domains
:::

:::card{title="Inbound Webhooks" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/Inbound.cs" icon="arrow-up-right-from-square"}
Receive and process inbound emails
:::

:::card{title="Double Opt-in" href="https://github.com/resend/resend-examples/blob/main/dotnet-resend-examples/Examples/DoubleOptinSubscribe.cs" icon="arrow-up-right-from-square"}
Double opt-in subscription flow
:::

:::card{title="Minimal API App" href="https://github.com/resend/resend-examples/tree/main/dotnet-resend-examples/MinimalApiApp" icon="arrow-up-right-from-square"}
ASP.NET Minimal API application
:::

:::card{title="MVC App" href="https://github.com/resend/resend-examples/tree/main/dotnet-resend-examples/MvcApp" icon="arrow-up-right-from-square"}
ASP.NET MVC application
:::
::::

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
