/// <summary> /// 使用SmtpClient发送电子邮件 /// </summary> /// <param name="title">标题</param> /// <param name="htmlBody">正文</param> /// <returns></returns> public static bool HoverTreeSendEmail(string title, string htmlBody) { bool result = false; SmtpClient h_smtpClient = new SmtpClient(); h_smtpClient.Host = SmptStr; MailMessage h_mailMessage = new MailMessage(); h_mailMessage.From = new MailAddress(""); string to_splits = ""; List <string> tos = new List <string>(); if (to_splits.IndexOf(",") > -1) { tos = to_splits.Split(',').ToList(); } else { tos.Add(to_splits); } foreach (var curuser in tos) { h_mailMessage.To.Add(curuser); } //h_mailMessage.To.Add(System.Configuration.ConfigurationManager.AppSettings["mailTo"]); h_mailMessage.Subject = title; h_mailMessage.Body = htmlBody; h_mailMessage.IsBodyHtml = true; h_smtpClient.UseDefaultCredentials = false; System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(Sendadress, Pwd); h_smtpClient.Credentials = basicAuthenticationInfo; h_smtpClient.EnableSsl = true; try { h_smtpClient.Send(h_mailMessage); result = true; } catch (Exception ex) { result = false; LogToText.WriteLog("Monitor.Console.Common.Mail.SendMail():" + ex.Message, LogType.Error); } return(result); }
public TradeDepot() { InitializeComponent(); var log = new LogToText(this.txtLog, this); captureScreen = new CaptureScreen(log); touch = new Touch(log); tradeWindow = new TradeWindow(captureScreen, log); tradePanelCapture = new TradePanelCapture(tradeWindow); buildingSelector = new BuildingSelector(log, touch); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); tradeWindow.PictureBox = this.pictureBox1; var pictureBoxes = new List <PictureBox>(); var textBoxes = new List <TextBox>(); pictureBoxes.Add(this.pb1); pictureBoxes.Add(this.pb2); pictureBoxes.Add(this.pb3); pictureBoxes.Add(this.pb4); pictureBoxes.Add(this.pb5); pictureBoxes.Add(this.pb6); pictureBoxes.Add(this.pb7); pictureBoxes.Add(this.pb8); textBoxes.Add(this.tb1); textBoxes.Add(this.tb2); textBoxes.Add(this.tb3); textBoxes.Add(this.tb4); textBoxes.Add(this.tb5); textBoxes.Add(this.tb6); textBoxes.Add(this.tb7); textBoxes.Add(this.tb8); itemHashes = new ItemHashes(pictureBoxes, textBoxes); itemHashes.ReadHashes(); salesman = new Salesman(touch, tradeWindow, tradePanelCapture, itemHashes, navigateToBuilding, log); }