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

How to send email to multiple recipients in C# with System.Net.Mail

Codemia Knowledge Hub ·

To send one email to several recipients with System.Net.Mail, add each address to the MailMessage.To collection and call Send once. The rest is getting the details right: valid addresses, SMTP configuration, exception handling, and whether some recipients belong in Cc or Bcc.

Add each recipient to MailMessage.To

Each call to To.Add appends another recipient:

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.";

Send the message

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

When addresses come from configuration or user input, loop over them instead of hard-coding To.Add calls:

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}

Cc and Bcc work the same way

CC and Bcc are also collections:

csharp
message.CC.Add("[email protected]");
message.Bcc.Add("[email protected]");
  • To is for direct recipients.
  • Cc is for visible copied recipients.
  • Bcc is for hidden copied recipients.

Picking the right one matters in bulk or compliance-sensitive mail, where recipient privacy counts.

Handle send errors explicitly

Sending can fail because of bad credentials, invalid addresses, SMTP server rejection, DNS issues, or TLS misconfiguration. Catch the exceptions so failures are visible instead of silently losing mail:

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}

Dispose the message and client with using

MailMessage and SmtpClient are disposable, so scope them with using. Cleanup then happens even if an exception is thrown:

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);

Clean up recipient input and add display names

Trim and validate addresses that come from user input:

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

Pass a MailAddress when you want explicit parsing or a display name:

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

Is SmtpClient still a good choice?

System.Net.Mail.SmtpClient still exists and works, so it is fine for learning how multi-recipient mail works in .NET. Many developers prefer newer libraries for more advanced workflows, but the address-handling model is the same idea: populate the address collections correctly rather than calling Send many times.

Mistakes to avoid

  • Concatenating several addresses into one malformed string instead of adding them to the collection.
  • Mixing up To, Cc, and Bcc when recipient privacy matters.
  • Skipping exception handling, which leaves you unable to tell whether the server rejected the message or the code failed before sending.
  • Wrong SMTP host, port, credentials, or SSL settings. Multi-recipient logic is irrelevant if the transport is misconfigured.

Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms