I have been using this code for quite some time.
Recently, detected increased memory consumption while
testing in one scenario. If the smtp server
authentication fails at line 9/11 , an smtp exception
gets thrown (correct behaviour). However, the memory
usage keeps increasing when this code is being called
by a windows service. What could be causing this ?
--------------------------------------------
private bool SendEmail (ref MailMessage msg)
{
// Send email
try
{ Smtp openSmtp = null;
//Send email
if (smtpServerInfo.Login.Length < 1 ||
smtpServerInfo.Password.Length < 1)
{
openSmtp = new
Smtp(smtpServerInfo.ServerAddress,Int32.Parse(smtpServerInfo.PortNumber));
}
else
{
openSmtp = new Smtp(smtpServerInfo.ServerAddress,
smtpServerInfo.Login,smtpServerInfo.Password,Int32.Parse(smtpServerInfo.PortNumber));
}
openSmtp.SendMail(msg);
}
return true;
}
catch(SmtpException e)
{
}
----------------------------------
Any help on this is mucho appreciated.
Kevin