Send email with C#

Microsoft's own docs mark SmtpClient obsolete for new development. Sending email from C# is one PostAsJsonAsync with the HttpClient you already use.

Verified By Kam Low, Co-founder · Updated

SmtpClient is deprecated. HttpClient is not.

System.Net.Mail.SmtpClient carries a warning straight from Microsoft: don't use it for new development. The suggested alternatives are third-party mail libraries, which means dependencies, SMTP credentials, and connection management, or the HTTP path with zero of those.

One POST, and the send is handled

C#POST /v1/my/messages
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
  new("Bearer", Environment.GetEnvironmentVariable("NITROSEND_API_KEY"));

await http.PostAsJsonAsync(
  "https://api.nitrosend.com/v1/my/messages",
  new { from = "[email protected]", to = "[email protected]",
        subject = "Welcome", html = "<p>You're in.</p>" });

ASP.NET Core, a worker service, or a console app: same call, one env var, and the anonymous object serializes itself.

One craft note from a decade of sends: if your email is mostly images, Gmail and Outlook cannot read it, so they guess, and the guess is the promotions tab or spam. Alt text on every image tells the inbox what the message is, and it changes where you land. We consider it important enough that the platform auto-fixes missing template alt text for you.

Full parameters, responses, and error codes live in the REST API docs and the API reference.

Python Node.js PHP Go Rust +5
send.py requests ยท stdlib-adjacent
import requests

requests.post(
  "https://api.nitrosend.com/v1/messages",
  headers={"Authorization": f"Bearer {KEY}"},
  json={"to": to, "subject": subj,
        "html": body})
202 ACCEPTED
{ "id": "msg_9f2c",
  "status": "accepted" }

And the part no library gives you

The same account exposes an MCP server, so the agent writing your code can also run your email. Point Claude, Cursor, or Codex at api.nitrosend.com/mcp and it composes, previews, and stages sends, with a human approving every one. The API is for your code. The MCP is for your agent. One platform either way.

Every send comes back with a message ID, and delivery events follow on your webhook: delivered, opened, bounced. No dashboard required to know what happened. If you are staying on SMTP, how to set up SMTP is the setup to follow, and SPF, DKIM and DMARC authentication is what stops those sends landing in spam.

Go deeper

Step back from the C# syntax for a second. The real fix for "how do I send email in C#" is not a cleaner HttpClient call, it is not writing the call at all. Tell Claude, Cursor, or Codex what the email should say and our MCP server drafts and sends it on the same account and key, no SDK reference open in another tab.

Guides

FAQ

How do I send email from C#?

PostAsJsonAsync to the email API with an anonymous object: from, to, subject, html. Bearer token on the default headers. No SmtpClient, no mail library.

What replaced SmtpClient?

Microsoft recommends against SmtpClient for new code. The practical replacement is an email API over HttpClient: less code than a mail library and it includes deliverability and delivery events.

First send in thirty seconds.

Simple pricing. Unlimited contacts.

Every plan includes full stack emailing: Flows, Newsletter Campaigns and Transactional Email, plus our NitroWheel LLM and all agent integrations (Claude, ChatGPT, Codex, Cursor and others). Pay for what you send, not who you store.

Daily allowances depend on your plan and sender standing. Strong list, domain and delivery evidence can raise standing, including on day one. Trusted receives the full plan allowance; available email credits, safety checks and delivery pacing still apply.

Free
$0
forever
  • Emails 8,000then 500/mo
  • Email types Transactional & Marketing
  • AI actions 20/mo
  • Contacts Free & Unlimited
  • Brands 3
  • Seats 1
  • Recipients / rolling 24h 100โ€“5,000
  • Email validation Prepaid only
Start free
Ultra
$100
per month
  • Emails 125,000/month
  • AI actions 5,000/mo
  • Brands 10
  • Seats 10 · Domains 10
  • Frontier AI Included
  • Dedicated IP Available
  • Recipients / rolling 24h 1,000โ€“625,000
  • Email validation Prepaid only
Get started
Enterprise
$300
per month
  • AI actions Unlimited
  • Unlimited brands & domains Included
  • SSO / SAML Included
  • 99.9% SLA Included
  • Recipients / rolling 24h Contracted
  • Email validation Prepaid only
Get started

Free forever. No credit card required. See full comparison →