static void Main(string[] args) { EmailInfoRepository ei = new EmailInfoRepository(); EmailInfoEntity info = ei.Get("27"); try { #region 设置基本信息 CDO.Message oMsg = new CDO.Message(); Configuration conf = new ConfigurationClass(); conf.Fields[CdoConfiguration.cdoSendUsingMethod].Value = CdoSendUsing.cdoSendUsingPort; conf.Fields[CdoConfiguration.cdoSMTPAuthenticate].Value = CdoProtocolsAuthentication.cdoBasic; conf.Fields[CdoConfiguration.cdoSMTPUseSSL].Value = false; conf.Fields[CdoConfiguration.cdoSMTPServer].Value = "smtp.sina.com";//必填,而且要真实可用 conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value = 25; conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value = "*****@*****.**"; conf.Fields[CdoConfiguration.cdoSendUserName].Value = "*****@*****.**"; //真实的邮件地址 conf.Fields[CdoConfiguration.cdoSendPassword].Value = "5e5d277c167bd275"; //为邮箱密码,必须真实 //5e5d277c167bd275 conf.Fields.Update(); oMsg.Configuration = conf; #endregion 设置基本信息 #region htmlbody string bodyStr = "test11"; List <string> strList = MailHelper.GetHtmlImageUrlList(bodyStr); Dictionary <string, string> dicImage = new Dictionary <string, string>(); foreach (var str in strList) { string key = Guid.NewGuid().ToString(); string newUrl = "cid:" + key; bodyStr = bodyStr.Replace(str, newUrl); dicImage.Add(key, str); } oMsg.HTMLBody = info.EmailFilePath; #endregion StringBuilder title = new StringBuilder(); title.Append("=?BIG5?B?"); title.Append(ToBase64("titleTest")); title.Append("?="); oMsg.Subject = title.ToString(); oMsg.From = "\"" + "River" + "\"" + "*****@*****.**"; ;//真实的邮件地址 #region BCC StringBuilder bccs = new StringBuilder(); bccs.Append("[email protected];"); oMsg.BCC = bccs.ToString(); #endregion BCC oMsg.HTMLBodyPart.Charset = "BIG5"; oMsg.Send(); } catch (Exception ex) { throw ex; } }