public string sendMail(MailContent md)
        {
            ResultInfo rAjaxResult = new ResultInfo();
            try
            {
                md.vaild = md.vaild.ToUpper();//轉大寫
                if (Session["mail"].ToString() != md.vaild)
                {
                    rAjaxResult.result = false;
                    rAjaxResult.message = "驗證碼不正確";
                    return defJSON(rAjaxResult);
                };
                var open = openLogic();
                using (db0 = getDB0())
                {
                    #region 信件發送
                    string Body = getMailBody("Email", md);//套用信件版面
                    string mailTitle = "承信推高機-線上諮詢";
                    string receiveMails = (string)open.getParmValue(ParmDefine.receiveMails);
                    string BccMails = (string)open.getParmValue(ParmDefine.BccMails);
                    Boolean mail;
                    mail = Mail_Send(md.email, //寄信人
                                    receiveMails.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries), //收信人
                                    BccMails.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries), //收信人(密件副本)
                                    mailTitle, //信件標題
                                    Body, //信件內容
                                    true); //是否為html格式
                    if (mail == false)
                    {
                        rAjaxResult.result = false;
                        rAjaxResult.message = "信箱號碼不正確或送信失敗";
                        return defJSON(rAjaxResult);
                    }
                    #endregion
                }
                rAjaxResult.result = true;

            }
            catch (Exception ex)
            {
                rAjaxResult.result = false;
                rAjaxResult.message = ex.Message;
            }
            return defJSON(rAjaxResult);
        }
Пример #2
0
        public string sendOrderMail(MailContent md)
        {
            ResultInfo r = new ResultInfo();
            try
            {
                if (this.isLogin)
                {
                    using (db0 = getDB0())
                    {
                        #region 設定會員
                        int member_id = int.Parse(this.MemberId);
                        var getMember = db0.Member.Find(member_id);
                        md.member_id = getMember.member_id;
                        md.member_name = getMember.member_name;
                        #endregion
                        #region 信件發送
                        string Body = getMailBody("OrderEmail", md);//套用信件版面
                        Boolean mail;
                        #region 收信人及寄信人
                        string sendMail = openLogic().getReceiveMails()[0];
                        //if (sendMail != "")
                        //{
                        //    var m = sendMail.Split(':');
                        //    sendMail = m[m.Length - 1];
                        //}

                        List<string> r_mails = openLogic().getReceiveMails().ToList();
                        if (!r_mails.Any(x => x == getMember.email) & getMember.email != null) { r_mails.Add(getMember.member_name + ":" + getMember.email); }

                        #endregion
                        mail = Mail_Send(sendMail, //寄信人
                                        r_mails.ToArray(), //收信人
                                        CommWebSetup.OrderMailTitle, //信件標題
                                        Body, //信件內容
                                        true); //是否為html格式
                        if (mail == false)
                        {
                            r.result = false;
                            r.message = "信箱號碼不正確或送信失敗!";
                            return defJSON(r);
                        }
                        postOrderContent(md);
                        #endregion
                    }
                    r.result = true;
                }
                else
                {
                    r.result = false;
                    r.message = "未登入會員無法下單~!";
                }
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            return defJSON(r);
        }