How do I avoid a delay when sending email from my application?
问题 I have a small console application. It checks a few settings, makes some decisions, and sends an email. The problem is the email doesn't actually get sent until my application finishes. I want the email sent as soon as my method that sends the email completes. Initially, I just created a MailMessage and called .Send(). That's when I noticed the mail was not being sent until the app finished. Then I tried using the task parallel library. var taskA = Task.Factory.StartNew(() => msg.Send());