MailAddress in .NET

I am trying to send an email and instead of sending 5 individual emails to each person, I would like to send one bulk message to all 5 people. The difference here is that I want everyone to appear on the "TO" or "CC" lines. How can i do this?

+1


a source to share


3 answers


This will only send one message:



MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("jdoe1@example.com", "Optional Name"));
msg.To.Add(new MailAddress("jdoe2@example.com"));
msg.To.Add(new MailAddress("jdoe3@example.com"));
msg.CC.Add(new MailAddress("jdoe4@example.com"));
msg.CC.Add(new MailAddress("jdoe5@example.com"));

// can add to BCC too
// msg.Bcc.Add(new MailAddress("jdoe5@example.com"));

msg.Body = "...";
msg.Subject = "...";

SmtpClient smtp = new SmtpClient();
smtp.Send(msg);

      

+6


a source


using System.Net.Mail;

...

MailMessage mmsg = new MailMessage();
mmsg.To.Add(new MailAddress("joe@user.com"));
mmsg.To.Add(new MailAddress("fred@user.com"));
mmsg.To.Add(new MailAddress("bob@user.com"));

// set other properties here...

SmtpClient client = new SmtpClient("mymailserver.com");
client.Send(mmsg);

      



Edit: everyone, john's fingers are faster than mine;)

+3


a source


MailMessage.CC.Add (new email (address))

Check out: http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.cc.aspx

+2


a source







All Articles