使用C#发送邮件时我们可以添加多少个电子邮件地址

时间:2014-06-14 19:33:33

标签: c# email

请参阅以下代码,该代码将邮件添加到foreach loo中的地址。所以我想知道我可以添加到MailAddress class多少个最大电子邮件地址谢谢

var list = from c in context.Emails orderby c.EmailAddress select c.EmailAddress;
MailMessage mail = new MailMessage();
try
{

    mail.From = new MailAddress(txtfrom.Text);
    foreach (var c in list)  
    {  
        mail.To.Add(new MailAddress(c.ToString()));
    }
    mail.Subject = txtSub.Text;
    mail.IsBodyHtml = true;
    mail.Body = txtBody.Text;
    if (FileUpload1.HasFile)
    {
        mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
    }
    SmtpClient smtp = new SmtpClient();
    smtp.Send(mail); 
}
catch (Exception)
{
    //exception handling
}

1 个答案:

答案 0 :(得分:1)

无限我想?这是一个MailAddressCollection