I’ve noticed that the majority of the example code using .NET’s SmtpClient class don’t Dispose the created object or wrap it in an using block. (e.g. http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx) Is the SmtpClient’s dispose optional or not very important or are the examples leading us down the wrong path? Note: In the MSDN example provided above the MailMessage is disposed but not the SmtpClient object.
I’ve noticed that the majority of the example code using .NET’s SmtpClient class don’t
Share
The reason that a lot of examples online don’t show proper disposing code is that SmtpClient didn’t implement IDisposable until .NET 4. So the examples could be based on a previous framework, or written by someone unfamiliar with the new functionality.