使用C#完成QQ发送邮件(简单使用)
2020-12-28 12:29
标签:form turn str div ret style orm pcl com 使用C#完成QQ发送邮件(简单使用) 标签:form turn str div ret style orm pcl com 原文地址:https://www.cnblogs.com/Kai-YoungMaster/p/13306544.html class QQEmail {
public bool IsSetEmail(string FromAddress, string ToAddress, string Message,string Pwd) {
MailAddress Address = new MailAddress(FromAddress);//
MailMessage mail = new MailMessage();//
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Subject = "这是" + FromAddress + "发送的一段信息:";
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.Body =Message;//
mail.IsBodyHtml = true;
mail.Priority = System.Net.Mail.MailPriority.Low;
mail.To.Add(ToAddress);//
mail.From = Address;
SmtpClient smtp = new SmtpClient("smtp.qq.com",25);//smtp支持的服务器是smtp.qq.com,服务器端口是25,587也行
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;//
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential( FromAddress,Pwd);//切记这两个数据一定要填对
try {
smtp.Send(mail);
return true;
}catch (Exception ex) {
System.Windows.Forms.MessageBox.Show(ex.Message);
return false;
}
}
}
}
上一篇:delphi实现起泡提示效果
下一篇:Windows命令提示符的使用
文章标题:使用C#完成QQ发送邮件(简单使用)
文章链接:http://soscw.com/index.php/essay/38825.html