MailMessage mail = new MailMessage();
mail.Subject = toAddress.Text;
mail.From = new MailAddress("a@sohu.com");
mail.To.Add(toAddress.Text);
mail.Subject = subjectText.Text;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = mailRichTextBox.Text;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = false;
SmtpClient client = new SmtpClient();
client.Credentials=new System.Net.NetworkCredential("a@sohu.com","1111");
client.Host = "pop3.sohu.com";
try
{
client.Send(mail);
MessageBox.Show("邮件发送成功");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
C#smtp发送邮件
最新推荐文章于 2024-04-12 10:13:13 发布