public static FacadeClass Build(string SourceCode, ConfigurationClass Class) { var syntaxTree = CSharpSyntaxTree.ParseText(SourceCode); var root = (CompilationUnitSyntax)syntaxTree.GetRoot(); var walker = new FacadeClassWalker(); walker.Visit(root); if (walker.IsInterface) { return(null); } return(new FacadeClass { Type = ParseFacadeType(walker.ClassModifers[0]), Name = walker.ClassNames[0], Usings = walker.Usings.OrderBy(S => S.Length).ThenBy(S => S).ToArray(), ParentNamespace = walker.DeclaredNamespaces[0], ClassModifier = walker.ClassModifers[0].Aggregate((S0, S1) => $"{S0} {S1} ").TrimEnd(' '), Methods = walker.Methods .Where(M => Class.ExcludedMethods == null || Class.ExcludedMethods != null && !Class.ExcludedMethods.Contains(M.Name)) .Where(M => Class.IncludedMethods == null || Class.IncludedMethods != null && Class.IncludedMethods.Contains(M.Name)) .OrderBy(S => S.Name).ToArray(), Constructors = walker.Constructors.ToArray() }); }
internal MKCommonPageElements(ConfigurationClass configuration) : base() { if (configuration.isBrowser) { } else if (configuration.isAndroid) { } else if (configuration.isIOS) { } }
internal MKSettingsElements(ConfigurationClass configuration) : base() { if (configuration.application.Equals(AppTypeData.Browser)) { } else if (configuration.application.Equals(AppTypeData.Android)) { } else if (configuration.application.Equals(AppTypeData.IOS)) { } }
private void MainForm_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); Rectangle rect = SystemInformation.WorkingArea; this.Height = rect.Height; this.Width = rect.Width; this.MaximizedBounds = new Rectangle(rect.X, rect.Y, rect.Width - 2, rect.Height - 2); MyTabs(); MyWorkPanel(); MyStatusPanel(); CNCShowForm(FormName.Form_WorkStatus); tLPJogKye.Visible = false; MyTable(); ControlBufferAll(); ConfigData configData = new ConfigData(); ConfigurationClass.AddUpdateAppSettings("TodoXMLFilePath", Application.StartupPath + "\\TodoList.xml"); FolderForm.pathsChanged += FolderForm_pathsChanged; }
public static MailState SendSSLEmail(string account, string passwd, string server, MailInfo mailInfo, string[] attach) { Message mailMessage = new Message(); //CDO.IConfiguration iConfg; //iConfg = oMsg.Configuration; //ADODB.Fields oFields; //oFields = iConfg.Fields; Configuration conf = new ConfigurationClass(); conf.Fields[CdoConfiguration.cdoSendUsingMethod].Value = CdoSendUsing.cdoSendUsingPort; conf.Fields[CdoConfiguration.cdoSMTPAuthenticate].Value = CdoProtocolsAuthentication.cdoBasic; conf.Fields[CdoConfiguration.cdoSMTPUseSSL].Value = true; conf.Fields[CdoConfiguration.cdoSMTPServer].Value = server;//必填,而且要真实可用 conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value = 465; conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value = account; conf.Fields[CdoConfiguration.cdoSendUserName].Value = account; //真实的邮件地址 conf.Fields[CdoConfiguration.cdoSendPassword].Value = passwd; //为邮箱密码,必须真实 conf.Fields.Update(); mailMessage.Subject = mailInfo.Subject; mailMessage.Configuration = conf; //oMsg.TextBody = "Hello, how are you doing?"; mailMessage.HTMLBody = mailInfo.MailBody; //TODO: Replace with your preferred Web page //oMsg.CreateMHTMLBody("http://www.microsoft.com",CDO.CdoMHTMLFlags.cdoSuppressNone, "", ""); mailMessage.From = account; mailMessage.To = mailInfo.ToAddress.Address; //oMsg.AddAttachment("C:\Hello.txt", "", ""); foreach (string file in attach)//物理路径 { if (string.IsNullOrEmpty(file)) { continue; } mailMessage.AddAttachment(file, "", ""); } mailMessage.Send(); return(MailState.Ok); }
public void SendEmail(string emailTo, string emailCC, string subjects, string body, string attachmentStream, string attachementFileName) { try { 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 = true; conf.Fields[CdoConfiguration.cdoSMTPServer].Value = "smtp.163.com"; //必填,而且要真实可用 conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value = "465"; //465特有 conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value = "<" + "*****@*****.**" + ">"; conf.Fields[CdoConfiguration.cdoSendUserName].Value = "*****@*****.**"; //真实的邮件地址 conf.Fields[CdoConfiguration.cdoSendPassword].Value = "asdqwe123"; //为邮箱密码,必须真实 conf.Fields.Update(); oMsg.Configuration = conf; // oMsg.TextBody = System.Text.Encoding.UTF8; //Message.BodyEncoding = System.Text.Encoding.UTF8; oMsg.BodyPart.Charset = "utf-8"; oMsg.HTMLBody = body; oMsg.Subject = subjects; oMsg.From = "*****@*****.**"; oMsg.To = emailTo; oMsg.CC = emailCC; //ADD attachment. //TODO: Change the path to the file that you want to attach. //oMsg.AddAttachment("C:\Hello.txt", "", ""); //oMsg.AddAttachment("C:\Test.doc", "", ""); oMsg.Send(); } catch (System.Net.Mail.SmtpException ex) { throw ex; } //System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); //client.Host = "smtp.163.com";//使用163的SMTP服务器发送邮件 //client.Port = 465; ////client.UseDefaultCredentials = true ; //client.UseDefaultCredentials = true; //client.Timeout = 5000; //client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "asdqwe123"); ////这里假定你已经拥有了一个163邮箱的账户,用户名为abc,密码为******* //System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage(); //Message.From = new System.Net.Mail.MailAddress("*****@*****.**");//这里需要注意,163似乎有规定发信人的邮箱地址必须是163的,而且发信人的邮箱用户名必须和上面SMTP服务器认证时的用户名相同 ////因为上面用的用户名abc作SMTP服务器认证,所以这里发信人的邮箱地址也应该写为[email protected] ////Message.To.Add("*****@*****.**");//将邮件发送给Gmail //Message.To.Add(emailTo);//将邮件发送给QQ邮箱 //if (!string.IsNullOrEmpty(emailCC)) //{ // Message.CC.Add(emailCC); //} //Message.Subject = subjects; //Message.Body = body; //// Message.Attachments.Add(new System.Net.Mail.Attachment(@"C:\Workspace\com.yrtech.Bentley\com.yrtech.bentleyAPI\com.yrtech.InventoryAPI\Content\Excel\LeadsReport.xlsx", System.Net.Mime.MediaTypeNames.Application.Octet)); //Message.SubjectEncoding = System.Text.Encoding.UTF8; //Message.BodyEncoding = System.Text.Encoding.UTF8; //Message.Priority = System.Net.Mail.MailPriority.High; //Message.IsBodyHtml = true; //CommonHelper.log("Email:"+emailTo + " " + subjects); //Thread.Sleep(500); //client.Send(Message); }
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; } }
internal MKSettingsPage(ConfigurationClass configuration) : base(configuration) { this.iwebdriver = configuration.driver; }
public async Task <Response> Retirar(float monto, ConfigurationClass oConfiguracion, Cuenta cuenta, int Estado) { try { if (oConfiguracion.UltimoRetiro.ToShortDateString() != DateTime.Now.ToShortDateString()) { oConfiguracion.RetiroDiario = 0; } if (monto > 400) { return(new Response { IsSuccess = false, Message = "El monto a retirar es mayor al permitido" }); } if ((oConfiguracion.RetiroDiario + monto) > 1000) { return(new Response { IsSuccess = false, Message = "Se excede el limite permitido" }); } if (cuenta.Saldo - monto < 0) { return(new Response { IsSuccess = false, Message = "No puede retirar una cantidad mayor a su saldo actual" }); } Usuario user = db.Usuario.FirstOrDefault(x => x.id_Usuario.Equals(cuenta.Usuario.id_Usuario)); var index = user.Cuenta.ToList().FindIndex(x => x.id_Cuenta.Equals(cuenta.id_Cuenta)); user.Cuenta.ToList()[index].Saldo -= monto; user.Cuenta.ToList()[index].Activo = Estado; user.Transaccion.Add(new Transaccion { Accion = "Retirar", Fecha = DateTime.Now, Monto = monto, NuevoSaldo = user.Cuenta.ToList()[index].Saldo, NumeroCuenta = cuenta.NumeroCuenta }); if (Estado == 0) { user.Transaccion.Add(new Transaccion { Accion = "Desactivo", Fecha = DateTime.Now, Monto = 0, NuevoSaldo = 0, NumeroCuenta = cuenta.NumeroCuenta, }); } db.Entry(user).State = System.Data.Entity.EntityState.Modified; var resp = await db.SaveChangesAsync(); if (resp > 0) { return(new Response { IsSuccess = true, Message = "El retiro fue exitoso", Result = user }); } else { return(new Response { IsSuccess = false, Message = "Error al actualizar el registro" }); } } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message }); } }
private async void RetirarDinero() { if (float.Parse(this.montotxt.Text) == 0) { string script = string.Format("alert('{0}');", "La cantidad a retirar es invalida"); ClientScript.RegisterStartupScript(this.GetType(), "alert", script, true); return; } int Estado = 1; float monto = float.Parse(this.montotxt.Text); int index = this.drpCuenta.SelectedIndex; ConfigurationClass oConf; var respu = db.ValidarMinimo(LoggedUser.Cuenta.ToList()[index], monto); if (!respu.IsSuccess) { //Preguntar si desea proseguir, si desea proseguir, cambiar Estado a 0 //ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "confirmClient()", true); //var proseguir = this.HiddenField1.ClientID; //if (bool.Parse(proseguir)) //{ // Estado = 0; //} //else //{ // return; //} Estado = 0; } try { oConf = new ConfigurationClass { RetiroDiario = float.Parse(Session["RetiroDiario"].ToString()), UltimoRetiro = DateTime.Parse(Session["UltimoRetiro"].ToString()) }; } catch (Exception ex) { Session["RetiroDiario"] = 0; oConf = new ConfigurationClass { RetiroDiario = 0, UltimoRetiro = DateTime.Now }; } var resp = await db.Retirar(monto, oConf, LoggedUser.Cuenta.ToList()[index], Estado); if (resp.IsSuccess) { Session["RetiroDiario"] = double.Parse(Session["RetiroDiario"].ToString()) + monto; Session["UltimoRetiro"] = DateTime.Now; Session["LoggedUser"] = resp.Result; string script = string.Format("alert('{0}');", resp.Message); ClientScript.RegisterStartupScript(this.GetType(), "alert", script, true); } else { //Mostrar el error string script = string.Format("alert('{0}');", resp.Message); ClientScript.RegisterStartupScript(this.GetType(), "alert", script, true); } }
public void Constructor() { configurationClass = new ConfigurationClass(); }
public void SendEmail(EmailInfo emailInfo, EmailAccount emailAccount, List <EmailSendBccAccount> toMails, List <EmailSendBccAccount> successList = null, List <EmailSendBccAccount> FailureList = null) { 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 = emailAccount.EmailAccountSMTP;//必填,而且要真实可用 conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value = emailAccount.EmailAccountSMTPPort; conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value = emailAccount.EmailAccountAddress; conf.Fields[CdoConfiguration.cdoSendUserName].Value = emailAccount.EmailAccountAddress; //真实的邮件地址 conf.Fields[CdoConfiguration.cdoSendPassword].Value = emailAccount.EmailAccountPassWord; //为邮箱密码,必须真实 conf.Fields.Update(); oMsg.Configuration = conf; #endregion 设置基本信息 #region htmlbody string bodyStr = emailInfo.EmailFilePath; 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 = bodyStr; #endregion StringBuilder title = new StringBuilder(); title.Append("=?BIG5?B?"); title.Append(ToBase64(emailInfo.EmailTitle)); title.Append("?="); oMsg.Subject = title.ToString(); oMsg.From = "\"" + emailAccount.EmailAccountName + "\"" + emailAccount.EmailAccountAddress; ;//真实的邮件地址 #region BCC StringBuilder bccs = new StringBuilder(); foreach (EmailSendBccAccount to in toMails) { try { //还要加上邮箱的正确性检验 if (!string.IsNullOrEmpty(to.EmailBccAccountInfo.EmailBccAccountAddress)) //&& MailHelper.IsEmail(to.EmailBccAccountInfo.EmailBccAccountAddress)) { bccs.Append(to.EmailBccAccountInfo.EmailBccAccountAddress + ";"); successList.Add(to); } else { FailureList.Add(to); } } catch (Exception ex) { LogHelper.Error("Panther.Email.Services.SendEmail.CDOSendEmail", "SetBcc", ex.Message, ex); FailureList.Add(to); } } oMsg.BCC = bccs.ToString(); LogHelper.Info(string.Format("發送郵箱:{0},收件箱:{1}", oMsg.From, oMsg.BCC)); #endregion BCC oMsg.HTMLBodyPart.Charset = "BIG5"; foreach (var imgUrl in dicImage) { oMsg.AddRelatedBodyPart(imgUrl.Value, imgUrl.Key, CdoReferenceType.cdoRefTypeId); } oMsg.Send(); } catch (Exception ex) { successList.Clear(); FailureList = toMails; LogHelper.Error("Panther.Email.Services.SendEmail.CDOSendEmail", "SendEmail", ex.Message, ex); throw ex; } }
static void Main(string[] args) { ConfigurationClass oCfg = new ConfigurationClass(); IMSClasses.RabbitMQ.MessageQueue oRBFormatQueue = new MessageQueue(oCfg.RabbittMQ.Server, "", oCfg.RabbittMQ.ExcelQueueName); /*IMSClasses.RabbitMQ.MessageQueue oRBExcelQueuePurge = new MessageQueue(oCfg.RabbittMQ.Server, "", oCfg.RabbittMQ.ExcelQueueName); oRBExcelQueuePurge.purgeQueue(); oRBExcelQueuePurge.close();*/ //oRBQueue.purgeQueue(); //oRBQueue.addMessage(2); while (true) { Console.WriteLine("Waiting for Jobs............."); Int64 iTaskID = oRBFormatQueue.waitConsume(); bool bCorrect = true; String sError = ""; System.Data.DataTable dt = null; IMSClasses.DBHelper.db oDB = new IMSClasses.DBHelper.db(oCfg.ConnectionString); System.Data.DataRow oRowTask = null; try { oRowTask = oDB.getTask(iTaskID); } catch(Exception eNotFound) { bCorrect = false; } if(bCorrect) { IMSClasses.Jobs.Task oCurrentTask = IMSClasses.Jobs.Task.getInstance(oRowTask["JSON"].ToString()); try { String sTemplatePath = System.IO.Path.Combine(oCfg.Paths.MainFolder, oCurrentTask.oJob.JOBCODE); String sOutputPath = System.IO.Path.Combine(oCfg.Paths.MainFolder, oCurrentTask.oJob.JOBCODE); sTemplatePath = System.IO.Path.Combine(sTemplatePath, oCfg.Paths.TemplateFolder); sOutputPath = System.IO.Path.Combine(sOutputPath, oCfg.Paths.OutFolder); oCurrentTask.oJob.InputParameters.SetupTemplatePaths(sTemplatePath); oCurrentTask.oJob.OutputParameters.SetupPath(sOutputPath); //String sJson = oCurrentJob.Serialize(); Console.WriteLine("Executiong of Format for job ID --> " + oCurrentTask.TaskID.ToString()); try { //dt = IMSClasses.excellHelpper.ExcelHelpper.getExcelData(oCurrentJob.InputParameters.Files[0].FileName, oCurrentJob.SQLParameters.TableName); //ExcelHelpper.executeExcelTemplate(@"C:\Dev\IMS\bin\Templates\Top50Farmacias\Top50Farmacias\bin\Release\Top50Farmacias.xltx"); ExcelHelpper.executeExcelTemplate(oCurrentTask.oJob.InputParameters.TemplateFile.FileName); } catch (Exception xlException) { bCorrect = false; sError = "Error formatting excel --> Exception --> " + xlException.Message; } oRBFormatQueue.markLastMessageAsProcessed(); //oRowTask = oDB.getTask(iTaskID); oRowTask = oDB.getJob(oCurrentTask.oJob.JOBID); IMSClasses.Jobs.Job oCurrentJob = IMSClasses.Jobs.Job.getInstance(oRowTask["JSON"].ToString()); if (!bCorrect || oCurrentJob.ReportStatus.Status.Equals("ERRO")) { //failure update /*oCurrentJob.ReportStatus.ExecutionDate = DateTime.Now; oCurrentJob.ReportStatus.Message = sError; oCurrentJob.ReportStatus.Status = "ERRO";*/ Console.WriteLine(" <<Error>> " + sError); oCurrentTask.UpdateDate = DateTime.Now; oCurrentTask.TaskComments = oCurrentJob.ReportStatus.Message; oCurrentTask.StatusFinal = oCurrentJob.ReportStatus.Status; oCurrentTask.StatusCurrent = oCurrentJob.ReportStatus.Status; } else { //correct job update /*como vamos por task y queremos manterlo estructurado en el servidor, vamos a mover el fichero generado*/ foreach (String sFile in System.IO.Directory.GetFiles(oCurrentJob.OutputParameters.DestinationFile.Directory)) { System.IO.FileInfo oFileInfo = new System.IO.FileInfo(sFile); String sNewPath = System.IO.Path.Combine(oCurrentJob.OutputParameters.DestinationFile.Directory, oCurrentTask.TaskID.ToString()); if (!System.IO.Directory.Exists(sNewPath)) System.IO.Directory.CreateDirectory(sNewPath); oFileInfo.MoveTo(System.IO.Path.Combine(sNewPath, oFileInfo.Name)); } oCurrentTask.oJob.ReportStatus.ExecutionDate = DateTime.Now; oCurrentTask.oJob.ReportStatus.Message = "Format excel correctly"; oCurrentTask.oJob.ReportStatus.Status = "DONE"; oCurrentTask.UpdateDate = DateTime.Now; oCurrentTask.TaskComments = "Format excel correctly"; oCurrentTask.StatusFinal = "DONE"; oCurrentTask.StatusCurrent = "DONE"; Console.WriteLine(" <<DONE>> " + oCurrentTask.StatusCurrent + " -- Date: " + oCurrentTask.UpdateDate.ToString()); } oDB.updateJob(oCurrentTask.oJob.Serialize(), oCurrentTask.oJob.JOBID); oDB.updateTask(oCurrentTask); } catch (Exception eTaskProccess) { oCurrentTask.StatusCurrent = "ERRO"; oCurrentTask.StatusFinal = "ERRO"; oCurrentTask.TaskComments = "ERROR >> " + eTaskProccess.Message.ToString(); oDB.updateTask(oCurrentTask); } } else { oRBFormatQueue.markLastMessageAsProcessed(); } } }
internal MKMatrixPage(ConfigurationClass configuration) : base(configuration) { this.iwebdriver = configuration.driver; }
public void SendEmail(EmailInfoEntity emailInfo, EmailAccountEntity emailAccount, List <EmailSendBccAccountEntity> toMails) { 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 = emailAccount.EmailAccountIsSSL == 1; conf.Fields[CdoConfiguration.cdoSMTPServer].Value = emailAccount.EmailAccountSMTP;//必填,而且要真实可用 conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value = emailAccount.EmailAccountSMTPPort; conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value = emailAccount.EmailAccountAddress; conf.Fields[CdoConfiguration.cdoSendUserName].Value = emailAccount.EmailAccountAddress; //真实的邮件地址 conf.Fields[CdoConfiguration.cdoSendPassword].Value = emailAccount.EmailAccountPassWord; //为邮箱密码,必须真实 conf.Fields.Update(); oMsg.Configuration = conf; #endregion 设置基本信息 #region htmlbody string bodyStr = emailInfo.EmailFilePath; 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 = bodyStr; #endregion StringBuilder title = new StringBuilder(); title.Append("=?BIG5?B?"); title.Append(ToBase64(emailInfo.EmailTitle)); title.Append("?="); oMsg.Subject = title.ToString(); oMsg.From = "\"" + emailAccount.EmailAccountName + "\"" + emailAccount.EmailAccountAddress; ;//真实的邮件地址 #region BCC StringBuilder bccs = new StringBuilder(); foreach (EmailSendBccAccountEntity to in toMails) { try { //还要加上邮箱的正确性检验 if (!string.IsNullOrEmpty(to.EmailBccAccountAddress)) //&& MailHelper.IsEmail(to.EmailBccAccountInfo.EmailBccAccountAddress)) { bccs.Append(to.EmailBccAccountAddress + ";"); to.EmailSendBccAccountState = 1; to.Result = "成功"; } else { to.EmailSendBccAccountState = -1; to.Result = "收件箱地址不正确"; } } catch (Exception ex) { to.EmailSendBccAccountState = -1; to.Result = "收件箱地址不正确:" + ex.Message; } } oMsg.BCC = bccs.ToString(); #endregion BCC oMsg.HTMLBodyPart.Charset = "BIG5"; foreach (var imgUrl in dicImage) { oMsg.AddRelatedBodyPart(imgUrl.Value, imgUrl.Key, CdoReferenceType.cdoRefTypeId); } lock (SendLock) { Constants.SleepInterval(Constants.SendWaitTime); LogHelper.Debug(string.Format("CDOSendEmail 发送邮件开始: 发件箱【{0}:{1}】发送邮件【{2} ->{3}】", emailAccount.EmailAccountID, emailAccount.EmailAccountAddress, emailInfo.EmailID, emailInfo.EmailTitle)); oMsg.Send(); LogHelper.Debug(string.Format("CDOSendEmail 发送邮件完成: 发件箱【{0}:{1}】发送邮件【{2} ->{3}】完成", emailAccount.EmailAccountID, emailAccount.EmailAccountAddress, emailInfo.EmailID, emailInfo.EmailTitle)); } } catch (Exception ex) { LogHelper.Error(string.Format("CDOSendEmail 发送邮件异常: 发件箱【{0}:{1}】发送邮件【{2} ->{3}】Exception:{4}", emailAccount.EmailAccountID, emailAccount.EmailAccountAddress, emailInfo.EmailID, emailInfo.EmailTitle, ex.Message), ex); throw ex; } }