Send product email from .NET. Use the HttpClient you already manage.
Send transactional email and publish lifecycle events from C# services and hosted workers with the Send & Retain API.
✓Reuse IHttpClientFactory in ASP.NET or a hosted worker. No static client setup to hide.
One request, complete trace
Request
POST /api/v1/emails
Authorization: Bearer aem_…
Idempotency-Key: welcome-8f21
{ "to": "[email protected]", "template": "welcome" }
202 Accepted
{ "id": "msg_7ca31", "status": "queued" }
[ 01 / 04 ]Client contract
Make email a typed service with observable outcomes.
Use IHttpClientFactory
Configure a named or typed client with the base URL, timeout, and server-side credential.
Send typed payloads
Use records and typed options for sender, recipients, template, and props.
Handle delivery events
Read HttpRequest.Body before model binding, so signature verification sees the raw payload.
[ 02 / 04 ]Server quickstart
Queue one email from .NET.
Server-side only, idempotent by key, and it returns an ID you can trace.
Reuse an injected HttpClient and set a stable idempotency key per message.
using var request = new HttpRequestMessage(HttpMethod.Post, EmailUrl);
request.Headers.Authorization = new("Bearer", apiKey);
request.Headers.Add("Idempotency-Key", $"welcome-{user.Id}");
request.Content = JsonContent.Create(new { to = user.Email, template = "welcome" });
var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();Accepted response
{ "id": "msg_7ca31", "status": "queued" }[ 03 / 04 ]Quickstart
Register once, then call from the application boundary.
Register a typed HTTP client
Load the API key through configuration and centralize timeout and response handling.
Await the accepted response
Send after the product action commits and pass the request cancellation token through.
Persist the message ID
Attach the identifier to your command or job record for delivery tracing.
Production checklist
- Secrets stay server-side
- Timeout and retry policy
- Idempotent webhook handler
- Structured error logging
[ 04 / 04 ]Related
Use .NET in context
Questions people ask us
Queue your first .NET email.
Register the client once, send from a service, and retain the delivery trace.