【发布时间】:2017-01-05 20:07:59
【问题描述】:
我有一个文本框(textBox2),电子邮件在哪里:
thisemail@gmail.com,hello@yahoo.it,YesOrNo@gmail.com,etc..
我有一个发送电子邮件的功能:
private void button1_Click(object sender, EventArgs e)
{
var mail = new MailMessage();
var smtpServer = new SmtpClient(textBox5.Text);
mail.From = new MailAddress(textBox1.Text);
mail.To.Add(textBox2.Text);
mail.Subject = textBox6.Text;
mail.Body = textBox7.Text;
mail.IsBodyHtml = checkBox1.Checked;
mail.Attachments.Add(new Attachment(textBox9.Text));
var x = int.Parse(textBox8.Text);
smtpServer.Port = x;
smtpServer.Credentials = new System.Net.NetworkCredential(textBox3.Text, textBox4.Text);
smtpServer.EnableSsl = checkBox2.Checked;
smtpServer.Send(mail);
}
我希望您分别向每封电子邮件发送一封电子邮件。
也就是说,当我按button1 一次给他发一封电子邮件并发送电子邮件直到你结束。我该怎么办?
【问题讨论】:
-
“一封邮件到每封邮件”是什么意思?当
textBox2.Text中有多个收件人时? -
split 字符串然后循环遍历您返回的数组中的项目。
标签: c# email text textbox take