我正在尝试发送电子邮件,而不是向每个人发送5封电子邮件,我想向所有5个人发送一封大量电子邮件。这里的不同之处在于我希望每个人都出现在“TO”或“CC”行中。我怎么能这样做?
答案 0 :(得分: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);
答案 1 :(得分: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);
编辑:哇,约翰的手指比我快;)
答案 2 :(得分:2)
MailMessage.CC.Add(新邮件地址(地址))
退房:http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.cc.aspx