.net 退出邮箱登陆的问题
用.net进行发送邮件后,当我再次对此邮件进行操作时总是提示该文件进程被占用。
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new NetworkCredential("我的邮箱","密码");
MailMessage mm = new MailMessage();
mm.CC.Add("对方邮箱");
mm.Attachments.Add(new Attachment("附件路径");
smtp.Send(mm);
------解决方案--------------------using (Attachment attachment = new Attachment(附件路径))
{
mm.Attachments.Add(attachment);
smtp.Send(mm);
}