调用的地方
- C# code
private void SendMail() { MailHelper mh = new MailHelper(); mh.To = "xxx@xx.com"; mh.CC = "xxx@xx.com"; mh.BCC = "xxx@xx.com"; mh.Subject = string.Format(CommonStatic.MAIL_SUBJECT, DateTime.Now.ToString("yyyyMMdd")).ToString(); ArrayList file_name = new ArrayList(); file_name.Add(string.Format(CommonStatic.EXCEL_NAME_ONE, DateTime.Now.ToString("yyyyMMdd")) + CommonStatic.EXCEL_NAME_END); file_name.Add(string.Format(CommonStatic.EXCEL_NAME_TWO, DateTime.Now.ToString("yyyyMMdd")) + CommonStatic.EXCEL_NAME_END); mh.Attachments = file_name; mh.SendEmail(true); }
MailHelper
- C# code
MailMessage msgMail = new MailMessage(); msgMail.From = new MailAddress(m_from); msgMail.To.Add(this.m_to); if (this.cc.Length > 0) { msgMail.CC.Add(this.cc); } if (this.bcc.Length > 0) { msgMail.Bcc.Add(this.bcc); } msgMail.Subject = m_subject; msgMail.IsBodyHtml = m_IsBodyHtml; if (m_Attachments != null) { for (int i = 0; i < m_Attachments.Count; i++) { System.Net.Mail.Attachment mailAttachment = new System.Net.Mail.Attachment(m_Attachments[i].ToString()); msgMail.Attachments.Add(mailAttachment); } } msgMail.Body = m_body; msgMail.BodyEncoding = m_MailEncoding; msgMail.SubjectEncoding = m_MailEncoding; if (verify) { msgMail.Headers.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication msgMail.Headers.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", m_smtpUserName); //set your username here msgMail.Headers.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", m_smtpPassword); //set your password here } SmtpClient smtp = new SmtpClient(m_smtpServer); //smtp邮件服务器 smtp.Send(msgMail); msgMail.Dispose();
报错:在头名中找到无效的字符。
window7 .net4.0
求解,谢谢
------解决方案--------------------------------------------------------
你网是代理网吗 ?有代理就发不出去
------解决方案--------------------------------------------------------
我的百度有:http://hi.baidu.com/gdlpc88/blog/item/d2dfb62cc2310e5a4fc22641
------解决方案--------------------------------------------------------
用 webmail pro 6 for asp.net