Example #1
0
    public static void SendEmailSuccess(int UserID)
    {
        Model_Setting s = new Model_Setting();

        s = s.GetSetting();

        Model_Users user = GetUserbyID(UserID);

        string body = string.Empty;
        string text = File.ReadAllText(HttpContext.Current.Server.MapPath("/Theme/emailtemplate/layout_sgSuccess.html"), Encoding.UTF8);

        if (!string.IsNullOrEmpty(text))
        {
            //string path = ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString().Replace("/admin", "") + "Verify?ID=" + StringUtility.EncryptedData(user.UserID.ToString());
            //body = text.Replace("<!--##@Linkverfiy##-->", path);
            //body = text.Replace("<!--##@Linkverfiy_btn##-->", path);

            body = text;
        }

        MailSenderOption option = new MailSenderOption
        {
            MailSetting = s,
            context     = HttpContext.Current,
            mailTo      = user.Email,
            Mailbody    = body,
            Subject     = "การสมัครของคุณเสร็จสิ้น/ You've successfully Register to Keen Profile System"
        };

        MAilSender.SendMailEngine(option);
    }
Example #2
0
    public static void SendEmailReceiveToStaff(object param)
    {
        object[]      parameters = (object[])param;
        string        staffmail  = (string)parameters[0];
        Model_Setting s          = (Model_Setting)parameters[1];
        HttpContext   context    = (HttpContext)parameters[2];


        Model_OrderPaymentTransferConfirm con = (Model_OrderPaymentTransferConfirm)parameters[3];
        int    intProductID = (int)parameters[4];
        string body         = string.Empty;
        string text         = "";

        if (intProductID == 1)
        {
            text = File.ReadAllText(context.Server.MapPath("/Theme/emailtemplate/layout_r3.html"), Encoding.UTF8);
        }

        if (intProductID == 2)
        {
            text = File.ReadAllText(context.Server.MapPath("/Theme/emailtemplate/layout_coaching.html"), Encoding.UTF8);
        }
        //if (!string.IsNullOrEmpty(text))
        //{
        //    string path = ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString().Replace("/admin", "") + "Verify?ID=" + StringUtility.EncryptedData(user.UserID.ToString());
        //    body = text.Replace("<!--##@Linkverfiy##-->", "<a href=\"" + path + "\" />here</a>");
        //}


        body = "FirstName : " + con.Name + "\r\n";
        body = body + "email : " + con.Email + "\r\n";
        body = body + "datetime : " + con.DatePayment.ToThaiDateTime() + "\r\n";


        List <MailSenderFileAtt> list = new List <MailSenderFileAtt>
        {
            new MailSenderFileAtt
            {
                FileName = "",
                Path     = con.FilePath
            }
        };

        foreach (string email in staffmail.Split(';'))
        {
            MailSenderOption option = new MailSenderOption
            {
                MailSetting = s,
                context     = HttpContext.Current,
                mailTo      = email,
                Mailbody    = body,
                Attachment  = list,
                Subject     = "[Keen Staff] การชำระค่าบริการเสร็จสมบูรณ์แล้ว / Success Payment Confirmation [Confirmed Order#" + con.OrderID + "]"
            };
            MAilSender.SendMailEngine(option);
        }
    }
Example #3
0
 private static string[] MailAddress(string mailadddress)
 {
     string[] arrS = { };
     if (!string.IsNullOrEmpty(mailadddress))
     {
         arrS = Array.FindAll(mailadddress.Split(';'), e => MAilSender.IsMatchEmail(e));
     }
     return(arrS);
 }
Example #4
0
    public static Model_Users SendEmailForgot(string email)
    {
        Model_Setting s = new Model_Setting();

        s = s.GetSetting();
        Model_Users user = GetUserbyEmailFront(email);


        if (user != null)
        {
            string body = string.Empty;
            string text = File.ReadAllText(HttpContext.Current.Server.MapPath("/Theme/emailtemplate/layoutforgot.html"), Encoding.UTF8);
            if (!string.IsNullOrEmpty(text))
            {
                string param       = user.UserID.ToString();
                string time        = DateTime.Now.ApiService_DateToTimestamp();
                string paramstring = param + "@" + time;

                HttpSessionState Hotels2Session = HttpContext.Current.Session;

                Hotels2Session.Clear();

                Hotels2Session.Timeout = 10;
                Hotels2Session[time]   = time;



                string path = ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString().Replace("/admin", "") + "ResetPassword?e=" + StringUtility.EncryptedData(paramstring);
                body = text.Replace("<!--##@Linkresetpassword##-->", path);
            }

            MailSenderOption option = new MailSenderOption
            {
                MailSetting = s,
                context     = HttpContext.Current,
                mailTo      = user.Email,
                Mailbody    = body,
                Subject     = "Forgot password and reset password"
            };
            MAilSender.SendMailEngine(option);
        }


        return(user);
    }
Example #5
0
    public static void SendEmaiReceiveToCustomer(object param)
    {
        object[] parameters = (object[])param;


        Model_Users   user    = (Model_Users)parameters[0];
        Model_Setting s       = (Model_Setting)parameters[1];
        HttpContext   context = (HttpContext)parameters[2];

        int intProductID = (int)parameters[3];


        string body = string.Empty;
        string text = string.Empty;

        if (intProductID == 1)
        {
            text = File.ReadAllText(context.Server.MapPath("/Theme/emailtemplate/layout_r3.html"), Encoding.UTF8);
        }

        if (intProductID == 2)
        {
            text = File.ReadAllText(context.Server.MapPath("/Theme/emailtemplate/layout_coaching.html"), Encoding.UTF8);
        }
        //if (!string.IsNullOrEmpty(text))
        //{
        //    string path = ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString().Replace("/admin", "") + "Verify?ID=" + StringUtility.EncryptedData(user.UserID.ToString());
        //    body = text.Replace("<!--##@Linkverfiy##-->", "<a href=\"" + path + "\" />here</a>");
        //}
        body = text;
        MailSenderOption option = new MailSenderOption
        {
            MailSetting = s,
            context     = HttpContext.Current,
            mailTo      = user.Email,
            Mailbody    = body,
            Subject     = "การชำระค่าบริการเสร็จสมบูรณ์แล้ว / Success Payment Confirmation"
        };

        MAilSender.SendMailEngine(option);
    }
Example #6
0
    public static void SendEmailReceiveToStaff()
    {
        Model_Setting s2 = new Model_Setting();

        s2 = s2.GetSetting();

        int intProductID = 1;



        string staffEmail = "[email protected];[email protected]";

        object[] param = new object[] { staffEmail, s2 };


        object[]      parameters = (object[])param;
        string        staffmail  = (string)parameters[0];
        Model_Setting s          = (Model_Setting)parameters[1];
        HttpContext   context    = HttpContext.Current;


        //Model_OrderPaymentTransferConfirm con = (Model_OrderPaymentTransferConfirm)parameters[3];

        string body = string.Empty;
        string text = "";

        if (intProductID == 1)
        {
            text = File.ReadAllText(context.Server.MapPath("/Theme/emailtemplate/layout_r3.html"), Encoding.UTF8);
        }

        if (intProductID == 2)
        {
            text = File.ReadAllText(context.Server.MapPath("/Theme/emailtemplate/layout_coaching.html"), Encoding.UTF8);
        }
        //if (!string.IsNullOrEmpty(text))
        //{
        //    string path = ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString().Replace("/admin", "") + "Verify?ID=" + StringUtility.EncryptedData(user.UserID.ToString());
        //    body = text.Replace("<!--##@Linkverfiy##-->", "<a href=\"" + path + "\" />here</a>");
        //}


        body = "FirstName : tet\r\n";
        body = body + "email : tet\r\n";
        body = body + "datetime : sss\r\n";

        FileInfo file = new FileInfo(HttpContext.Current.Server.MapPath("/orderconfirmfile/10033.jpg"));
        List <MailSenderFileAtt> list = new List <MailSenderFileAtt>();

        if (file.Exists)
        {
            list.Add(new MailSenderFileAtt
            {
                FileName = "",
                Path     = "/orderconfirmfile/10033.jpg"
            });
        }


        foreach (string email in staffmail.Split(';'))
        {
            MailSenderOption option = new MailSenderOption
            {
                MailSetting = s,
                context     = HttpContext.Current,
                mailTo      = email,
                Mailbody    = body,
                Attachment  = list,
                Subject     = "[Keen Staff] การชำระค่าบริการเสร็จสมบูรณ์แล้ว / Success Payment Confirmation "
            };
            MAilSender.SendMailEngine(option);
        }
    }
Example #7
0
    public static int SendQue()
    {
        Model_Campaign c = new Model_Campaign();
        Model_Mailbox  m = new Model_Mailbox();

        IList <Model_Campaign> cl = c.model_Que();
        IList <Model_Mailbox>  ml = m.model_Que();


        //SendingJob sj = new SendingJob();
        //SendingJobItem st = new SendingJobItem();



        foreach (Model_Campaign i in cl)
        {
            byte             mailStatus = 3;
            byte             jobstatus  = 1;
            Model_SendingJob sd         = new Model_SendingJob();

            try
            {
                bool IsinTime = QueIsinTime(i.DateTimePublish);
                IList <Model_Subscriber> sl = allSubscriber(i.SG);
                var sl_filter = sl.Where(e => MAilSender.IsMatchEmail(e.Email)).GroupBy(j => j.Email);

                int TotalSubscriber = sl_filter.Count();


                sd = QueAddJob(sd, i.IsSchedule, i.CID, TotalSubscriber, IsinTime, 1);


                //Sending

                if (sd.SDID > 0)
                {
                    QueAddJobItem(sd, sl_filter);
                }
            }
            catch
            {
            }

            sd.UpdateJobStatus(sd.SDID, jobstatus);
            i.model_updatestatus(i.CID, mailStatus);
            i.model_UpdateToJob(i.CID, true);
        }

        foreach (Model_Mailbox i in ml)
        {
            byte             mailStatus = 3;
            byte             jobstatus  = 1;
            Model_SendingJob sd         = new Model_SendingJob();
            try
            {
                bool IsinTime = QueIsinTime(i.DateTimePublish);
                IList <Model_Subscriber> sl = allSubscriber(i.SG);
                var sl_filter = sl.Where(e => MAilSender.IsMatchEmail(e.Email)).GroupBy(j => j.Email);

                string[] mailboxreciever = MailAddress(i.Mailaddress);


                int TotalSubscriber = sl_filter.Count();
                int Totalmailbox    = mailboxreciever.Count();

                sd = QueAddJob(sd, i.IsSchedule, i.CID, TotalSubscriber + Totalmailbox, IsinTime, 2);


                if (sd.SDID > 0)
                {
                    QueAddJobItem(sd, sl_filter, mailboxreciever);
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message + ex.StackTrace;
            }

            sd.UpdateJobStatus(sd.SDID, jobstatus);
            i.model_updatestatus(i.CID, mailStatus);

            i.model_UpdateToJob(i.CID, true);
        }



        return(SendNow());
    }
Example #8
0
    public static void Sendnow(object param)
    {
        object[] parameters             = (object[])param;
        List <Model_SendingJobItem> cli = (List <Model_SendingJobItem>)parameters[0];
        Model_Setting s = (Model_Setting)parameters[1];

        Model_SendingJob ms = (Model_SendingJob)parameters[2];

        HttpContext context = (HttpContext)parameters[3];
        //Model_SendingJob ms = new Model_SendingJob();

        //var groupCampaignCID = cli.Where(cam => cam.CType == 1).GroupBy(c => c.CID);
        //var groupMailboxCID = cli.Where(cam => cam.CType == 2).GroupBy(c => c.CID);

        //StringBuilder strCam = new StringBuilder();
        //StringBuilder strMailBox = new StringBuilder();
        //foreach (var ss in groupCampaignCID)
        //{
        //    int propertyIntOfClassA = ss.Key;
        //    strCam.Append(propertyIntOfClassA + ",");
        //}
        //strCam.Append("0");
        //foreach (var ss in groupMailboxCID)
        //{
        //    int propertyIntOfClassA = ss.Key;
        //    strMailBox.Append(propertyIntOfClassA + ",");
        //}
        //strMailBox.Append("0");


        IList <Model_Campaign> mdc = CampaignController.GetCampaign(ms.CID.ToString());
        IList <Model_Mailbox>  mdm = MailboxController.GetMailbox(ms.CID.ToString());

        MailSenderOption option = new MailSenderOption
        {
            MailSetting = s,
            context     = context
        };
        EmailEelements e = new EmailEelements();

        // _el = (EModel)e.model_GetElementBYID(this.EID).Eelement.JsonToObject(new EModel());
        int count = 1;

        foreach (Model_SendingJobItem c in cli)
        {
            if (c.CType == 1)
            {
                Model_Campaign cam = mdc.SingleOrDefault(r => r.CID == c.CID);
                EModel         el  = (EModel)cam.ELRaw.JsonToObject(new EModel());
                option.Subject = cam.Subject;

                string bodymail = el.html;
                if (cam.Unsub)
                {
                    bodymail = bodymail.Replace("</body>", appendSubscription(c.SID));
                }

                option.Mailbody = bodymail;

                if (!string.IsNullOrEmpty(cam.FileMail))
                {
                    option.Attachment = GetFileMail(cam.FileMail);
                }
            }
            else
            {
                Model_Mailbox cam = mdm.SingleOrDefault(r => r.CID == c.CID);
                EModel        el  = (EModel)cam.ELRaw.JsonToObject(new EModel());
                option.Subject = cam.Subject;

                string bodymail = appendHtmlforMailbox(el.html);
                if (cam.Unsub && c.SID != 0)
                {
                    bodymail = bodymail.Replace("</body>", appendSubscription(c.SID));
                }

                option.Mailbody = bodymail;

                if (!string.IsNullOrEmpty(cam.FileMail))
                {
                    option.Attachment = GetFileMail(cam.FileMail);
                }
            }
            option.mailTo = c.Email;

            //"*****@*****.**", "Gosolve", c.Email, "Thread Sending", "", "Thread Sending Thread Sending"
            if (MAilSender.SendMailEngine(option))
            {
                c.UpdateStatus(c.SDIID, true);
            }



            // Lock.AcquireWriterLock(Timeout.Infinite);

            //SendingEngineController.SendResponse.SingleOrDefault(ii => ii.CID == c.CID).TotalSent += 1;
            // Lock.ReleaseWriterLock();



            ms.UpdateTotalSentAndISDone(c.SDID);
            count = count + 1;
        }

        Lock.AcquireWriterLock(Timeout.Infinite);
        SendingEngineController.Onprocess = false;
        Lock.ReleaseWriterLock();
    }