MailMessage message = new MailMessage();
message.To.Add("[email protected]");
message.From = new MailAddress("[email protected]");
message.Subject = "SUBJECT SUBJECT";
message.SubjectEncoding = Encoding.UTF8;
message.Body = "Body Body";
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = false;
message.Priority = MailPriority.Normal;
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new System.Net.NetworkCredential("654321","password");
smtp.Host = "smtp.qq.com";
smtp.Port = 25;
object userState = message;
smtp.SendAsync(message,userState);
上面是代碼,不知道什麼問題,運行不報錯,就是收不到郵件。我是用的qq郵箱發的。
檢查下用戶名密碼端口和smtp服務器,另外你的qq郵箱是否啟用了smtp