电子邮件发送多个抄送地址

时间:2018-07-24 08:01:03

标签: c#

我必须发送具有多个抄送地址的邮件。 目前,此代码仅适用于一个。 这是代码:

MailAddress addressTo = new MailAddress("ma@.asd.a");
                            MailAddress addressFrom = new MailAddress("ma@.asd.a");
                            MailMessage MyMessage = new MailMessage("ma@.asd.a", "ma@.asd.a");

                            MyMessage.Subject = "New requests";
                            MyMessage.Body = @"Body";

                            MailAddress copy = new MailAddress("ma@.asd.a");
                            MyMessage.CC.Add(copy);

                            SmtpClient client = new SmtpClient();
                            client.Port = 32;
                            client.EnableSsl = false;
                            client.Host = "my-smtp";
                            client.Timeout = 10000;
                            client.DeliveryMethod = SmtpDeliveryMethod.Network;
                            client.Credentials = new System.Net.NetworkCredential(LocalUserName, "");

                            client.UseDefaultCredentials = false;

                            client.Send(MyMessage);

我已经准备好了:

MailAddress copy2 = new MailAddress("maas@.asd.a");
                            MyMessage.CC.Add(copy2)

但是它不起作用,请求有超时错误。

有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

只需将它们分别添加:

MyMessage.CC.Add("a@a.com");

或添加多个作为AddRange:

MyMessage.CC.AddRange("a@a.com", "b@b.com");