Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage
Posted
by StanleyGu
on ASP.net Weblogs
See other posts from ASP.net Weblogs
or by StanleyGu
Published on Thu, 01 Apr 2010 01:34:00 GMT
Indexed on
2010/04/01
2:13 UTC
Read the original article
Hit count: 560
1. It is quite straightforward using SmtpClient class to send out an email
2. However, when you step through the above code executing smtpClient.Send(), you will notice about 2 minutes delay in receiving the email.
3. My first try to solve the issue of delayed email is to set MaxIdleTime=1
4. The first try solves the issue of delayed email very well but introduces another issue: high CPU usage. The CPU usage of my deployed windows service is consistently at 50%, which is much higher than the expected near-zero CPU usage.
5. The second try is to set MaxIdleTime=2, which solves the both issues.
© ASP.net Weblogs or respective owner