Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

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.

 

 

Published Wednesday, March 31, 2010 9:34 PM by StanleyGu
Filed under: ,

Comments

# Twitter Trackbacks for Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage - StanleyGu's Blog [asp.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage - StanleyGu's Blog         [asp.net]        on Topsy.com

# re: Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

Thursday, April 01, 2010 5:27 AM by Guy harwood

Care to explain why this makes a difference?

# re: Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

Tuesday, July 06, 2010 9:54 AM by Ryan

OMG ... this is uber skillz ... spent two hours trying to figure this out ... who cares why! as long as it works!! Thanks!!!

# re: Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

Friday, August 13, 2010 10:51 AM by Jeremy

You, my good sir, are a gentleman and a scholar.  Fixed my problem.

Also, I happened to see a Microsoft post that stated this issue is corrected in .NET 4.0 so that's another option.

# re: Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

Thursday, May 26, 2011 11:57 PM by weblogs.asp.net

Tip 14 solve smtpclient issues of delayed email and high cpu usage.. Neat :)

# re: Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

Sunday, November 06, 2011 5:49 PM by Jason

You are a sanity saver!  This issue had been the bane of my existence over the past few days (using VS 2008).

# re: Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

Wednesday, January 25, 2012 4:08 PM by tareq

Thanks and really thanks...

i am with jason's comment, You are a sanity saver!

Leave a Comment

(required) 
(required) 
(optional)
(required)