好的,我的 linq 技能不是很好,所以我尝试执行以下操作。
假设我有 6000 条记录(电子邮件地址)我想将前 1000 条添加到密件抄送,发送,接下来的 1000 条添加到密件抄送,发送,将 1000 条添加到密件抄送,发送等....
开始写了,
string[] files = System.IO.Directory.GetFiles(@"C:\Mail\ ", "*.csv");
Parallel.ForEach(files, currentFile =>
{
string filename = currentFile;
StreamReader reader = new StreamReader(filename);
var emailList = new List<String>();
while (reader.Peek() >= 0)
{
emailList.Add(reader.ReadLine());
}
\\Here is where I need to do the linq?
IEnumerable<string> list = emailList
var message = new System.Net.Mail.MailMessage();
foreach (var s in list)
{
MailAddress mailAddress = new MailAddress(s);
message.Bcc.Add(mailAddress);
}
message.Subject = txtSubject.Text;
message.From = new System.Net.Mail.MailAddress(txtFrom.Text);
message.Body = txtMessage.Text;
message.IsBodyHtml = true;
var smtp = new System.Net.Mail.SmtpClient();
smtp.Send(message);