日期:2014-05-17  浏览次数:20622 次

怎样使用MailMessage发送邮件?
我用MailMessage类写了以下代码,想实现邮件的发送,但总是出现错误:“邮箱不可用。 服务器响应为: Óû§±»Ëø¶¨ ”请高手指点。  
  string file = Server.MapPath("testXML.xml");
  MailMessage myMail = new System.Net.Mail.MailMessage(); 
  myMail = new System.Net.Mail.MailMessage(txtSender.Text.Trim(), txtReceiver.Text.Trim(),txtSubject.Text.Trim(),txtContent.Text.Trim());
  if (ddlAccessories.Items.Count > 0)
  {
  for (int i = 0; i < ddlAccessories.Items.Count; i++)
  {
  System.Net.Mail.Attachment myAttachment = new System.Net.Mail.Attachment(Server.MapPath(ddlAccessories.Items[i].Value), System.Net.Mime.MediaTypeNames.Application.Octet);
  System.Net.Mime.ContentDisposition disposition = myAttachment.ContentDisposition;
  disposition.CreationDate = System.IO.File.GetCreationTime(file);
  disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
  disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
  myMail.Attachments.Add(myAttachment);
  }
  }
  System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.163.com", 25);
  client.Credentials = new System.Net.NetworkCredential("zs-work@163.com", "zs*875158");
  client.Send(myMail);


------解决方案--------------------
建议使用jmail,用MailMessage不稳!