我正在从我的网站发送电子邮件,但电子邮件部分很慢, 所以我决定尝试把它放在一个新的线程中, 并想出了这个
public bool sendmail()
{
Thread T1 = new Thread(delegate()
{
MailMessage eMail = new MailMessage();
SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"]);
string EmailFromGCBS = (ConfigurationManager.AppSettings["EmailFROM"]);
eMail.From = new MailAddress(EmailFromGCBS);
eMail.To.Add(new MailAddress(emailTo));
eMail.Subject = emailSubject;
eMail.IsBodyHtml = isHtml;
eMail.Body = emailBody;
smtpClient.Send(eMail);
});
T1.Start();
return true;
}
线程运行,但是没有发送任何电子邮件知道为什么会这样?