使用C#完成QQ发送邮件(简单使用) [操作系统入门]
class QQEmail {publicbool 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);
returntrue;
}catch (Exception ex) {
System.Windows.Forms.MessageBox.Show(ex.Message);
returnfalse;
}
}
}
}
View Code
使用C#完成QQ发送邮件(简单使用)
以上是 使用C#完成QQ发送邮件(简单使用) [操作系统入门] 的全部内容, 来源链接: utcz.com/z/518382.html