System.Net.Mail
email automation
C# programming
multiple email recipients
.NET framework

How to send email to multiple addresses using System.Net.Mail

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

To send email to multiple recipients with System.Net.Mail, add more than one address to the MailMessage.To collection before sending. The core idea is simple, but the surrounding details still matter: valid addresses, SMTP configuration, exception handling, and whether you also want Cc or Bcc.

Add Multiple Recipients to MailMessage.To

The most explicit approach is to add each recipient individually:

csharp
1using System.Net;
2using System.Net.Mail;
3
4var message = new MailMessage();
5message.From = new MailAddress("[email protected]");
6message.To.Add("[email protected]");
7message.To.Add("[email protected]");
8message.To.Add("[email protected]");
9message.Subject = "Project update";
10message.Body = "The deployment completed successfully.";

That is the basic pattern. Every call to To.Add appends another recipient.

Send the Message

Then configure the SMTP client and send:

csharp
1using var smtp = new SmtpClient("smtp.example.com", 587)
2{
3    Credentials = new NetworkCredential("[email protected]", "password"),
4    EnableSsl = true
5};
6
7smtp.Send(message);

If the SMTP settings are correct, the message goes to every address in To.

Add Recipients From a List

If your addresses come from configuration or user input, loop over them:

csharp
1using System.Collections.Generic;
2using System.Net.Mail;
3
4var recipients = new List<string>
5{
6    "[email protected]",
7    "[email protected]",
8    "[email protected]"
9};
10
11var message = new MailMessage();
12message.From = new MailAddress("[email protected]");
13
14foreach (var address in recipients)
15{
16    message.To.Add(address);
17}

This is cleaner than hard-coding repeated To.Add calls when the recipient set is dynamic.

Cc and Bcc Work the Same Way

You are not limited to the To field. Cc and Bcc are also collections:

csharp
message.CC.Add("[email protected]");
message.Bcc.Add("[email protected]");

Use:

  • 'To for direct recipients,'
  • 'Cc for visible copied recipients,'
  • 'Bcc for hidden copied recipients.'

That distinction matters more than people sometimes realize, especially in bulk or compliance-sensitive mail flows.

Handle Errors Explicitly

Email sending can fail for many reasons:

  • bad credentials,
  • invalid addresses,
  • SMTP server rejection,
  • DNS issues,
  • or TLS misconfiguration.

Wrap sending in exception handling:

csharp
1try
2{
3    smtp.Send(message);
4}
5catch (SmtpException ex)
6{
7    Console.WriteLine($"SMTP error: {ex.Message}");
8}
9catch (FormatException ex)
10{
11    Console.WriteLine($"Bad email address: {ex.Message}");
12}

This makes failures visible instead of silently losing mail.

Build the Message With using

Because MailMessage and SmtpClient are disposable, it is good practice to scope them cleanly:

csharp
1using var message = new MailMessage();
2message.From = new MailAddress("[email protected]");
3message.To.Add("[email protected]");
4message.To.Add("[email protected]");
5message.Subject = "Hello";
6message.Body = "This message has multiple recipients.";
7
8using var smtp = new SmtpClient("smtp.example.com", 587)
9{
10    Credentials = new NetworkCredential("[email protected]", "password"),
11    EnableSsl = true
12};
13
14smtp.Send(message);

This keeps the message-building code tidy and ensures cleanup happens even if an exception is thrown.

Validate or Normalize Recipient Input

If recipient addresses come from user input, trim and validate before adding them:

csharp
var raw = " [email protected] ";
message.To.Add(raw.Trim());

MailAddress can also be used directly when you want explicit parsing:

csharp
message.To.Add(new MailAddress("[email protected]", "Alice"));

This is useful when display names are part of the requirement.

About SmtpClient

System.Net.Mail.SmtpClient still exists and works, which makes it fine for understanding the mechanics of multi-recipient mail in .NET. For newer or more advanced email workflows, many developers prefer newer libraries, but the address-handling model shown here is still a useful foundation.

The key point for this article is that sending to multiple recipients is about populating the address collections correctly, not about calling Send multiple times.

Common Pitfalls

The biggest pitfall is trying to concatenate several addresses into one malformed string instead of adding them properly to the recipient collection.

Another mistake is confusing To, Cc, and Bcc, especially when recipient privacy matters.

Developers also often skip exception handling and then have no idea whether the SMTP server rejected the message or the code failed before sending.

Finally, make sure the SMTP credentials, host, port, and SSL settings match the server you are using. Multi-recipient logic is irrelevant if the transport configuration is wrong.

Summary

  • Add multiple recipients by calling MailMessage.To.Add more than once.
  • 'Cc and Bcc are separate collections with different visibility semantics.'
  • Loop over a list of addresses when recipients are dynamic.
  • Use using and exception handling around message creation and sending.
  • The hardest part is usually SMTP configuration, not adding multiple addresses.

Course illustration
Course illustration

All Rights Reserved.