The following lines cause a memory leak:
MailMessage msg = new MailMessage(mail, mail, "?", ""); msg.Attachments.Add(new Attachment(filePath, MediaTypeNames.Text.Plain)); var client = new SmtpClient("smtp.mail.ru", 25); client.Credentials = new NetworkCredential(mail, "password"); client.EnableSsl = true; client.Send(msg); client.Dispose(); msg.Attachments.Dispose(); msg.Dispose(); Is it possible to solve this problem? It seems all dispose caused.