c# - How to dispose an SmtpClient in .NET 3.5? -
i using smtpclient
send mail. how can dispose smtpclient
. using .net 3.5.
try { smtpclient.send(message); log.writespeciallog("smtpclient mail sending try success", ""); } catch (exception ee) { log.writespeciallog("smtpclient mail sending try failed : " + ee.tostring(), ""); return false; }
for .net 3.5, not being able proper dispose smtpclient know issue. http://connect.microsoft.com/visualstudio/feedback/details/146711/smtp-never-sends-the-quit-command
your question similar one: properly disposing resources used smtpclient
the issue has been fixed in .net 4.0 http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient(v=vs.100).aspx , (and many other reasson) advisible update .net framework (althought know upgrading issue).
but, if want dispose smtpclient
, can make class disposable yourself. don't know how goes smtpclient
. http://forums.asp.net/t/383218.aspx/1 http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx
as side note, advise handle catch smtpfailedrecipientsexception
, not treat exceptions generic. smtpstatuscode
in innerexception
gives important informations.
Comments
Post a Comment