1

我正在尝试发送一封电子邮件,而不是向每个人发送 5 封单独的电子邮件,我想向所有 5 个人发送一封群发电子邮件。这里的不同之处在于我希望每个人都出现在“TO”或“CC”行中。我怎样才能做到这一点?

4

3 回答 3

6

这将只发送一条消息:

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);
于 2009-05-14T21:34:09.850 回答
3
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);

编辑:噢,约翰的手指比我的快;)

于 2009-05-14T21:35:30.127 回答
2

MailMessage.CC.Add(新邮件地址(地址))

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

于 2009-05-14T21:34:25.653 回答