sos 问题描述:
收件人的邮箱地址是一个的时候正常,
当 收件人为多个时(例如:[email protected];[email protected];[email protected]),
报如下IE错误,  
烦请高手指导,积分奖利.在线等~~
 /**单击事件*/
protected void btnSubmit_Click(object sender, EventArgs e)
        {
        
                this.sendMailsII(this.txtForm.Text.Trim(),
                this.txtFormpwd.Text.Trim(),
                this.txtTo.Text.Trim(),
                this.txtTitle.Text.Trim(),
                this.txtCotent.Text.Trim(),
                this.FileUpload1.PostedFile.FileName.Trim(),
                this.txtCC.Text.Trim());//获取要添加的附件文件        }
private void sendMailsII(string mailForm, string mailFormPwd,string tomail, string subject, string body, string fileroad, string ccmail)
        {//Send mail use smtp.163.com server.... 
            MailMessage objMailMessage;
            objMailMessage = new MailMessage();
            objMailMessage.From = new MailAddress(mailForm, "*****Ricky Mail Test******");//使用指定的地址和显示名初始化 MailAddress 类的新实例            objMailMessage.To.Add(tomail);//获取包含此电子邮件的收件人地址集合,向集合中添加电子邮件地址
            objMailMessage.CC.Add(ccmail);//获取包含此电子邮件的抄送人地址集合,向集合中添加电子邮件地址
            objMailMessage.IsBodyHtml = true;//邮件正文是否为html格式
            objMailMessage.Subject = subject;//获取包含电子邮件的主题
            objMailMessage.Body = body;//获取包含电子邮件的的正文            //MailAttachment obj 
            Attachment mailattent = new Attachment(fileroad);//添加一个附件 
            objMailMessage.Attachments.Add(mailattent);//获取用于存储附加到此电子邮件的数据的附件集合            SmtpClient sclient = new SmtpClient("smtp.163.com");// 使用简单邮件传输协议 (SMTP) 来发送电子邮件
            sclient.Credentials = new System.Net.NetworkCredential(mailForm, mailFormPwd);
            try
            {
                sclient.Send(objMailMessage);
                this.Response.Write(" <script> alert('Sent Successfully.'); </script> ");
                this.txtTo.Text = "";
                this.txtForm.Text = "";
                this.txtFormpwd.Text = "";
                this.txtTitle.Text = "";
                this.txtCotent.Text = "";
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
            }
        }IE报错如下:行 123:            objMailMessage.From = new MailAddress(mailForm, "*****Ricky Mail Test******");//使用指定的地址和显示名初始化 MailAddress 类的新实例
行 124:
行 125:            objMailMessage.To.Add(tomail);//获取包含此电子邮件的收件人地址集合,向集合中添加电子邮件地址
行 126:            objMailMessage.CC.Add(ccmail);//获取包含此电子邮件的抄送人地址集合,向集合中添加电子邮件地址
行 127:            objMailMessage.IsBodyHtml = true;//邮件正文是否为html格式

解决方案 »

  1.   

    是否换一种方式,
    把收件人的邮箱放列表中,然后用for来循环收件人,这样,收件人地址就是单个收件人了.
      

  2.   

    怎么没人解答?
    难道只能用笨的方法list来做吗?
      

  3.   


    MailAddressCollection  就是一个集合啊,难道还有其他的文件要配置吗?
      

  4.   

    objMailMessage.To 的属性是 MailAddressCollection ,本身就是一个集合啊,难道还有其他的文件要配置吗?
      

  5.   

                这样才能添加到集合里面去,大家有更好的办法,互相交流下....            string tomail = "[email protected];[email protected] [email protected],[email protected]"
                char[] delimiterChars = { ' ', ',', ':', ';', '\t' };
                string[] _tomail = tomail.Split(delimiterChars);
                foreach (string s1 in _tomail)
                {
                    objMailMessage.To.Add(s1);
                }