Example #1
0
        /// <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;
            }
        }
Example #2
0
        //每半小时检测一次,如未发送过邮件且超过24小时,则发送
        public void SendEmailToUser()
        {
            string siteUrl  = SiteConfig.SiteInfo.SiteUrl + "/BU/Comment.aspx?p=";
            string mailHtml = EventDeal.Tlp_Read("订单成交24小时后_用户");

            //已支付,已满24小时,未发送过邮件的订单
            string where = "ParentID=0 AND (Payment!='' AND Payment IS NOT NULL) ";
            where       += " AND DATEDIFF(HOUR,AddTime,GETDATE())>=24";
            DataTable orderDT = DBCenter.Sel("ZL_OrderInfo", where);

            for (int i = 0; i < orderDT.Rows.Count; i++)
            {
                try
                {
                    DataRow     dr       = orderDT.Rows[i];
                    M_OrderList orderMod = new M_OrderList().GetModelFromReader(orderDT.Rows[i]);
                    string      url      = siteUrl + EncryptHelper.AESEncrypt(orderMod.id.ToString());
                    string      html     = mailHtml.Replace("{LinkUrl}", "<a href='" + siteUrl + "' target='_blank'>" + siteUrl + "</a>");
                    EventDeal.SendToEmail(orderMod.Email, "Order Comment", mailHtml, orderMod.id.ToString());
                    DBCenter.UpdateSQL(orderMod.TbName, "ParentID=1", "ID=" + orderMod.id);
                }
                catch (Exception ex) { ZLLog.L("邮件24小时通知 Error:[" + orderDT.Rows[i]["ID"] + "]" + ex.Message); }
            }
        }