Send with .NET
Send email from .NET 8+ with the usend SDK, plain HTTP or SMTP.
The usend .NET SDK uses only System.Net.Http and System.Text.Json. You need a verified domain and an API key. It targets .NET 8 or newer.
1. Install
dotnet add package Usend2. Send an email
using Usend;
using var usend = new UsendClient(Environment.GetEnvironmentVariable("USEND_API_KEY"));
try
{
var sent = await usend.Emails.SendAsync(new
{
from = "Acme <[email protected]>",
to = new[] { "[email protected]" },
subject = "Hello from usend",
html = "<p>It works!</p>",
});
Console.WriteLine($"queued: {sent.GetProperty("id").GetString()}");
}
catch (UsendException e)
{
Console.Error.WriteLine($"failed {e.StatusCode} {e.ErrorName}: {e.Message}");
}Responses are JsonElements. In ASP.NET Core, register one UsendClient as a singleton (or pass your IHttpClientFactory client through UsendClientOptions.HttpClient). Pass an idempotency key to make retries safe: SendAsync(email, UsendClient.NewIdempotencyKey()).
Verify a webhook
var evt = Webhook.Verify(rawBody, headers, Environment.GetEnvironmentVariable("USEND_WEBHOOK_SECRET")!);Plain HTTP and SMTP
You can skip the SDK: POST https://api.usend.et/emails with Authorization: Bearer <key> works from HttpClient.
System.Net.Mail.SmtpClient is obsolete for new code; use MailKit against smtp.usend.et port 587 (STARTTLS) or 465 with username usend and your API key (usend.GetSmtpConfig() returns these settings). See Send with SMTP.