/// <summary> /// 发送系统邮件 /// </summary> public static void SendOrderEmailByType(int oid, string type, string email = "") { M_OrderList orderMod = new B_OrderList().SelReturnModel(oid); if (string.IsNullOrEmpty(email)) { M_Order_Contact conMod = new B_Order_Contact().SelModelByOid(oid); email = conMod.Email; } switch (type) { case "order": //下单后(暂只用于测试) { StringWriter sw = new StringWriter(); HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Payed.aspx?ID=" + oid, sw); string title2 = "We received your order!"; string html2 = sw.ToString(); //throw new Exception(conMod.Email); SendToEmail(email, title2, html2, ""); } break; case "pay": //付款后 { OrderFinish(orderMod, null); } break; case "exp": { StringWriter sw = new StringWriter(); HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Send.aspx?ID=" + oid, sw); string title = "Order has been shipped"; string html = sw.ToString(); SendToEmail(email, title, html, ""); SnsHelper.UpdateOrderField(oid, "EMail_Exp", "1"); } break; case "after": { DataTable orderDT = DBCenter.Sel("ZL_OrderInfo", "ID=" + oid); string title = "Order Notify"; string html = Tlp_Read("订单后期调查"); html = EventDeal.TlpDeal(html, orderDT); SendToEmail(email, title, html, ""); SnsHelper.UpdateOrderField(orderMod.id, "EMail_After", "1"); SendToEmail(SiteConfig.SiteInfo.WebmasterEmail, title, html, ""); } break; } }
//仅负责将邮件再发送出去 public static void OrderFinish(M_OrderList mod, M_Payment pinfo) { //DataTable orderDT = DBCenter.Sel(mod.TbName, "ID=" + mod.id); //DataTable contactDT = DBCenter.Sel("ZL_Order_Contact", "OrderID=" + mod.id); //DataTable cartDT = DBCenter.JoinQuery("A.*,B.PreviewImg", "ZL_CartPro", // "ZL_Logo_Design", "A.Attribute=B.ID", "A.OrderListID="+mod.id+" AND (A.Attribute IS NOT NULL AND A.Attribute !='')"); //string userHtml = Tlp_Read("订单付款后_用户"); //userHtml = TlpDeal(userHtml, contactDT); //userHtml = TlpDeal(userHtml, orderDT); ////替换购物车列表 //string cartHead = "<table><tr><td>Name</td><td>Image</td><td>Unit Price</td><td>Quantity</td><td>Total</td></tr>"; //string cartHtml = ""; //string cartEnd = "</table>"; //foreach (DataRow dr in cartDT.Rows) //{ // var cartTlp = "<tr>" // + "<td>" // + "<div>{Proname}</div>" // + "<div>{ProInfo}</div>" // + "</td>" // + "<td><img src=\"{PreviewImg}\" width=\"160\" height=\"100\"/></td>" // + "<td>{Shijia}</td>" // + "<td>{Pronum}</td>" // + "<td>{AllMoney}</td>" // + "</tr>"; // cartHtml += TlpDeal(cartTlp, cartDT, dr); //} //cartHtml = cartHead + cartHtml + cartEnd; //userHtml = userHtml.Replace("{CartList}", cartHtml); ////发送邮件给双方 //SendToEmail(mod.Email, "Order Prompt", userHtml, mod.id+""); ////----------------------发送邮件通知管理员 //string adminHtml = Tlp_Read("订单付款后_管理员"); //adminHtml = TlpDeal(userHtml, contactDT); //adminHtml = TlpDeal(userHtml, orderDT); //adminHtml = adminHtml.Replace("{CartList}", cartHtml); StringWriter sw = new StringWriter(); HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Payed.aspx?ID=" + mod.id, sw); string title = "We received your order!"; string html = sw.ToString(); SendToEmail(mod.Email, title, html, mod.id.ToString()); SendToEmail(SiteConfig.SiteInfo.WebmasterEmail, title, html, mod.id.ToString()); SnsHelper.UpdateOrderField(mod.id, "EMail_Pay", "1"); }