public void SendScheduleEmail()
 {
     ClientBroadCastingService clientBroadCastingService = new ClientBroadCastingService();
     var q = clientBroadCastingService.GetEmailScheduler();
     foreach(var m in q)
     {
         if (DateTime.Now.Day == m.DateStamp.Value.Day && DateTime.Now.Month == m.DateStamp.Value.Month && DateTime.Now.Year == m.DateStamp.Value.Year)
         {
             if (m.Status != 1)
             {
                 string time = DateTime.Now.ToString("hh:mm");
                 if (time == "18:30")
                 {
                     SendEmail(m.MailTo, m.MailFrom, m.Title, m.Template);
                     clientBroadCastingService.ChangeStatusMailSchedule(m.MailScheduleId);
                     lblMessage.Text = "Schedule email has been sent";
                 }
             }
         }
     }
 }
        public void SenDripTemplate()
        {
            try
            {
                lblerror.Text = "Email schedular started on " + DateTime.Now;
                ClientBroadCastingService clientBroadCastingService = new ClientBroadCastingService();
                DripTempaleService dripTempaleService = new DripTempaleService();
                List<ClientCampaignModel> clientCampaign = new List<ClientCampaignModel>();
                ImageServices imageServices = new ImageServices();
                clientCampaign = GetClientLists();
                for (int i = 0; i < clientCampaign.Count; i++)
                {
                    var clientDetail = clientBroadCastingService.GetClientDetail(clientCampaign[i].ClientUserId).ToList();
                    var agentDetail = imageServices.GetAboutMe(clientCampaign[i].UserId).ToList();
                    if (clientCampaign[i].DateStamp.Value.Month == DateTime.Now.Month && clientCampaign[i].DateStamp.Value.Year == DateTime.Now.Year && clientCampaign[i].DateStamp.Value.Day == DateTime.Now.Day)
                    {
                        if (clientCampaign[i].Status == null)
                        {
                            var template = dripTempaleService.GetDripTemplateHtmlParticularId(clientCampaign[i].TemplateHtmlId);
                            var enote = dripTempaleService.GetParticularDripTemplates(clientCampaign[i].EnoteTemplateId);
                            template = template.Replace("enote header", enote.TemplateSubject);
                            template = template.Replace("enote description", enote.TemplateDescription);
                            template = template.Replace("agent name", agentDetail[0].FirstName + " " + agentDetail[0].LastName);
                            template = template.Replace("agent address", agentDetail[0].Address);
                            template = template.Replace("agent phone", agentDetail[0].Phone);
                            template = template.Replace("agent cell", agentDetail[0].Cell);
                            template = template.Replace("agent email", agentDetail[0].Email);
                            template = template.Replace("agent website", agentDetail[0].WebsiteName);
                            if (string.IsNullOrEmpty(agentDetail[0].AboutLogo))
                            {
                                template = template.Replace("aboutlogo", "http://myrealtyweb.com/DripTemplateHtml/photo.jpg");
                            }
                            else
                            {
                                template = template.Replace("aboutlogo", "http://myrealtyweb.com/Aboutmelogo/" + agentDetail[0].AboutLogo);
                            }
                            template = template.Replace("aboutlogo", "" + agentDetail[0].AboutLogo);
                            SendEmail(clientDetail[0].PrimaryEmail, agentDetail[0].FirstName + " " + agentDetail[0].LastName + "@myrealtyweb.com", enote.TemplateHeader, template);
                            lblMessage.Text = "Email has been sent to " + clientDetail[0].PrimaryEmail + " successfully on " + DateTime.Now;
                            dripTempaleService.UpdateDripStatus(clientCampaign[i].ClientCampaignId, 1);
                        }
                    }
                    else
                    {
                        lblMessage.Text = "No email sent right now calculated date is " + DateTime.Now;
                    }

                }
            }
            catch (Exception ex)
            {
                Helper hp = new Helper();
                hp.LogException(ex);
                lblMessage.Text = ex.Message;
            }
        }