SmtpClient MailAddress MailMessage
SmtpClient smtp = new SmtpClient();
smtp.Host = this.txtSmtp.Text;
smtp.Port = int.Parse(this.txtPort.Text);
smtp.Credentials = new NetworkCredential(this.txtAccount.Text, this.txtPwd.Text);
smtp.EnableSsl = false;
smtp.SendCompleted += new SendCompletedEventHandler(smtp_SendCompleted);
MailMessage mail = new MailMessage();
mail.From = new MailAddress(this.txtFrom.Text);
mail.Subject = this.txtSubject.Text;
mail.BodyEncoding = Encoding.UTF8;
mail.IsBodyHtml = false;
mail.Body = this.txtContent.Text;
string[] to = this.txtTo.Text.Split('|');
foreach (string item in to)
{
mail.To.Add(item);
}
try
{
smtp.SendAsync(mail,mail);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show(ex.ToString());
}