我正在尝试异步发送电子邮件,这样它就不会减慢我的前端(Asp.Net MVC)的速度。
SmtpClient smtp = new SmtpClient(_mailServer, 25);
smtp.UseDefaultCredentials = true;
MailMessage message = new MailMessage();
// ...etc
smtp.SendA(message); // this works fine
smtp.SendAsync(message, null); // if i change it to this, it doesn't work (mail never appears)
我真的不明白第二个参数SendAsync
是为了什么。
MSDN 说它是一个传递给操作完成时调用的方法的对象
好吧,wtf?什么方法?所以我刚刚尝试传递 null 因为我真的不明白这是为了什么,但显然有问题。