public string SendOptInEmail() { ClientOptionInOutService clientOptionInOutService = new ClientOptionInOutService(); ImageServices imageServices=new ImageServices(); var modal = clientOptionInOutService.GetClientsForRequestOpt(); var mailInOutTemplate = clientOptionInOutService.GetMailInoutTemplate(); string domainName=ConfigurationManager.AppSettings["domainname"]; foreach (var m in modal) { if(clientOptionInOutService.CheckNextOptInEmail(DateTime.Now,m.LoginUserId) == true) { var agentDetail = imageServices.GetAboutMe(m.UserId).ToList()[0]; mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentname", agentDetail.FirstName + " " + agentDetail.LastName); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentaddress", agentDetail.Address); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentemail", agentDetail.Email); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentphone",agentDetail.Phone); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentcell", agentDetail.Cell); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentwebsite", agentDetail.WebsiteName); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("?clientid", "?clientid="+m.LoginUserId+"&emaildd=" + m.ClientBroadCastingId); mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("clientname", m.FirstName + " " + m.LastName); if (string.IsNullOrEmpty(agentDetail.AboutLogo)) { mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentimage", "http://myrealtyweb.com/DripTemplateHtml/photo.jpg"); } else { mailInOutTemplate.MailInOutTemplate1 = mailInOutTemplate.MailInOutTemplate1.Replace("agentimage", "http://myrealtyweb.com/Aboutmelogo/" + agentDetail.AboutLogo); } string optInHtml = mailInOutTemplate.MailInOutTemplate1; SendEmail(m.PrimaryEmail, "*****@*****.**", "Request For Your Permission", optInHtml); clientOptionInOutService.ChangeStatusToSentMail(int.Parse(m.ClientBroadCastingId.ToString())); } } return "success"; }
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; } }