public static void SendEmail(MailEntity mailEntity) { TxtFileLogger logger = LoggerManager.GetLogger(); try { var mailService = ServiceBroker.FindService <IPP.Oversea.CN.ServiceCommon.ServiceInterfaces.ServiceContracts.ISendMail>(); var mail = new MailBodyV31 { Body = new MailBodyMsg { MailTo = mailEntity.To, CCMailAddress = mailEntity.CC, Subjuect = mailEntity.Subject, MailBody = mailEntity.Body, Status = 0, //0:未发送,1:已经发送 CreateDate = DateTime.Now, Priority = 1 // Normal } }; mail.Header = new MessageHeader(); mail.Header.CompanyCode = ConfigurationManager.AppSettings["CompanyCode"]; DefaultDataContract result = mailService.SendMail2IPP3Internal(mail); if (result.Faults != null && result.Faults.Count > 0) { throw new Exception(result.Faults[0].ErrorDescription); } } catch (Exception ex) { logger.WriteLog("邮件发送失败!\r\n" + ex.ToString()); } }
/// <summary> /// 发送问题回复列表Mail /// </summary> public static void SendQuestionList() { MailBodyV31 mailBody = new MailBodyV31(); mailBody.Body = new MailBodyMsg(); mailBody.Body.MailBody = GetQuestionListMailBody(); mailBody.Body.MailTo = ConfigurationManager.AppSettings["MailAddressTo"]; mailBody.Body.Subjuect = "用户询问回复情况表——" + DateTime.Now.Date.AddDays(-1).ToString("yyyy-MM-dd"); mailBody.Body.CCMailAddress = Convert.ToString(ConfigurationManager.AppSettings["CCMailAddress"]); QuestionListDA.SendMailQuestionList(mailBody); }
public static void SendMailQuestionList(MailBodyV31 mailBody) { DataCommand command = DataCommandManager.GetDataCommand("SendMailInfo"); command.SetParameterValue("@MailAddress", mailBody.Body.MailTo); command.SetParameterValue("@CCMailAddress", mailBody.Body.CCMailAddress); command.SetParameterValue("@MailSubject", mailBody.Body.Subjuect); command.SetParameterValue("@MailBody", mailBody.Body.MailBody); command.SetParameterValue("@CompanyCode", CompanyCode); command.SetParameterValue("@LanguageCode", LanguageCode); command.ExecuteNonQuery(); }
public static void SendMail(StringBuilder sb) { int year = DateTime.Now.Year; int month = DateTime.Now.Month; int day = DateTime.Now.Day; DateTime today = DateTime.Today; MailBodyV31 mb = new MailBodyV31(); mb.Body = new MailBodyMsg(); mb.Body.MailFrom = ConfigurationManager.AppSettings["MailAddress"]; mb.Body.MailTo = ConfigurationManager.AppSettings["MailAddress"]; mb.Body.MailBody = sb.ToString(); mb.Body.Subjuect = "" + year.ToString() + "年" + month.ToString() + "月" + day.ToString() + "日需要拍照商品Item#"; mb.Body.Status = 0; mb.Body.Priority = 0; Product_StatusDA.InsertMailDB(sb.ToString()); }
public void SendMail(MailEntity entity) { ISendMail service = ServiceBroker.FindService <ISendMail>(); MailBodyV31 mail = new MailBodyV31(); mail.Body = new MailBodyMsg { CCMailAddress = entity.CC, CreateDate = DateTime.Now, MailBody = entity.Body, MailFrom = entity.From, MailTo = entity.To, Subjuect = entity.Subject }; mail.Header = Util.CreateServiceHeader(); DefaultDataContract contract = service.SendMail2MailDBInternal(mail); if (contract != null && contract.Faults != null && contract.Faults.Count > 0) { MessageFault fault = contract.Faults[0]; throw new Exception(string.Format("{0}\r\n{1}\r\n{2}", fault.ErrorCode, fault.ErrorDescription, fault.ErrorDetail)); } }