MailAddress emailfrom = new System.Net.Mail.MailAddress("**********@sina.cn");
MailAddress emailto = new System.Net.Mail.MailAddress("********@qq.com");
MailMessage email = new System.Net.Mail.MailMessage(emailfrom, emailto);
//email.Bcc.Add(new System.Net.Mail.MailAddress(textBox2.Text.ToString().Trim()));
//email.CC.Add(new System.Net.Mail.MailAddress(textBox2.Text.ToString().Trim()));
email.Subject = textBox3.Text;
email.Body = richTextBox1.Text.ToString().Trim();
email.SubjectEncoding = System.Text.Encoding.UTF8;
email.IsBodyHtml = true;
email.Priority = System.Net.Mail.MailPriority.Normal;
SmtpClient smtpPC = new SmtpClient("smtp.sina.com.cn",25);
smtpPC.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpPC.Credentials = new System.Net.NetworkCredentia("用户名", "密码");
smtpPC.UseDefaultCredentials = false;
smtpPC.EnableSsl = true;
//MailMessage my = new MailMessage();
try
{
smtpPC.Send(email);
MessageBox.Show("ok,send email complete!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
MailAddress emailto = new System.Net.Mail.MailAddress("********@qq.com");
MailMessage email = new System.Net.Mail.MailMessage(emailfrom, emailto);
//email.Bcc.Add(new System.Net.Mail.MailAddress(textBox2.Text.ToString().Trim()));
//email.CC.Add(new System.Net.Mail.MailAddress(textBox2.Text.ToString().Trim()));
email.Subject = textBox3.Text;
email.Body = richTextBox1.Text.ToString().Trim();
email.SubjectEncoding = System.Text.Encoding.UTF8;
email.IsBodyHtml = true;
email.Priority = System.Net.Mail.MailPriority.Normal;
SmtpClient smtpPC = new SmtpClient("smtp.sina.com.cn",25);
smtpPC.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpPC.Credentials = new System.Net.NetworkCredentia("用户名", "密码");
smtpPC.UseDefaultCredentials = false;
smtpPC.EnableSsl = true;
//MailMessage my = new MailMessage();
try
{
smtpPC.Send(email);
MessageBox.Show("ok,send email complete!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
smtpHost=Smtp.gmail.com
SmtpClient client = new SmtpClient(smtpHost,587);
client.EnableSsl = true;
因为Gmail要求把ssl加密打开