static public bool SendEmailHandler(MemberEmail email, PrizeConstants.EmailType emailType, string emailSubject, List <string> additionalContents) { try { return(PrizeEmail.SendEmailByType(email.EmailAddress, emailType, emailSubject, additionalContents)); } catch (Exception e) { PrizeLogs.SaveSystemErrorLog(email.MemberId, email.EmailId, PrizeConstants.SystemErrorLevel.LevelNormal, "Email thread", "Sending email " + email.EmailType.ToString(), e); return(false); } }
static public bool SendEmailByType(string email, PrizeConstants.EmailType emailType, string emailSubject, List <string> additionalContents) { int nodeId = 0; int templateNodeId = 5332; if (emailType == PrizeConstants.EmailType.WelcomeEmail) { nodeId = 5333; } else if (emailType == PrizeConstants.EmailType.TwoDaysPrior2Start) { nodeId = 6671; } else if (emailType == PrizeConstants.EmailType.OneDaysPrior2Week4Normal) { nodeId = 5377; } else if (emailType == PrizeConstants.EmailType.OneDaysPrior2Week4Vegan) { nodeId = 9669; } else if (emailType == PrizeConstants.EmailType.OneDaysPrior2Week4Lactose) { nodeId = 9670; } else if (emailType == PrizeConstants.EmailType.OneDaysPrior2Week11) { nodeId = 9676; } else if (emailType == PrizeConstants.EmailType.ContinuousLogin) { nodeId = 6672; } else if (emailType == PrizeConstants.EmailType.NewYearEmail) { nodeId = 6681; } else if (emailType == PrizeConstants.EmailType.EasterEmail) { nodeId = 6680; } else if (emailType == PrizeConstants.EmailType.ChristmasEmail) { nodeId = 5385; } else if (emailType == PrizeConstants.EmailType.BirthdayEmail) { nodeId = 5380; } else if (emailType == PrizeConstants.EmailType.FirstMonthEmail) { nodeId = 6673; } else if (emailType == PrizeConstants.EmailType.SecondMonthEmail) { nodeId = 6674; } else if (emailType == PrizeConstants.EmailType.ThirdMonthEmail) { nodeId = 6675; } else if (emailType == PrizeConstants.EmailType.TwoDaysPrior2End) { nodeId = 6678; } else if (emailType == PrizeConstants.EmailType.OneDayPrior2TrialEnd) { nodeId = 6679; } else if (emailType == PrizeConstants.EmailType.MileStoneWeek2) { nodeId = 5379; } else if (emailType == PrizeConstants.EmailType.MileStoneWeek6) { nodeId = 5381; } else if (emailType == PrizeConstants.EmailType.MileStoneWeek10) { nodeId = 5382; } else if (emailType == PrizeConstants.EmailType.MileStoneWeek12) { nodeId = 5384; } else if (emailType == PrizeConstants.EmailType.MileStoneEndWeek12) { nodeId = 6683; } else if (emailType == PrizeConstants.EmailType.MileStoneGoalWeek13) { nodeId = 9675; } else if (emailType == PrizeConstants.EmailType.MileStoneWeek6) { nodeId = 5381; } else if (emailType == PrizeConstants.EmailType.MileStoneWeek10) { nodeId = 5382; } else if (emailType == PrizeConstants.EmailType.MeasurmentWeek4) { nodeId = 6682; } else if (emailType == PrizeConstants.EmailType.MeasurmentWeek7) { nodeId = 9673; } else if (emailType == PrizeConstants.EmailType.MeasurmentWeek10) { nodeId = 10873; } else if (emailType == PrizeConstants.EmailType.MeasurmentWeek12) { nodeId = 9674; } else if (emailType == PrizeConstants.EmailType.MeasurmentMissedWeek4) { nodeId = 5383; } else if (emailType == PrizeConstants.EmailType.MeasurmentMissedWeek7) { nodeId = 5383; } else if (emailType == PrizeConstants.EmailType.MeasurmentMissedWeek10) { nodeId = 5383; } else if (emailType == PrizeConstants.EmailType.MeasurmentMissedWeek12) { nodeId = 5383; } else if (emailType == PrizeConstants.EmailType.FisrtDayOnWeek1) { nodeId = 5378; } else if (emailType == PrizeConstants.EmailType.ReviveMeEmail) { int weekNum = 0; int.TryParse(additionalContents[1], out weekNum); switch (weekNum) { case 1: nodeId = 9707; break; case 2: nodeId = 11856; break; case 3: nodeId = 11857; break; case 4: nodeId = 11858; break; case 5: nodeId = 11859; break; case 6: nodeId = 11860; break; case 7: nodeId = 11861; break; case 8: nodeId = 11862; break; case 9: nodeId = 11863; break; case 10: nodeId = 11864; break; case 11: nodeId = 11865; break; case 12: nodeId = 11866; break; default: break; } } else if (emailType == PrizeConstants.EmailType.WelcomeEmailTrial) { nodeId = 12958; } else if (emailType == PrizeConstants.EmailType.ReviveMeEmailTrial) { int weekNum = 0; int.TryParse(additionalContents[1], out weekNum); switch (weekNum) { case 1: nodeId = 12957; break; case 2: nodeId = 12976; break; default: break; } } else if (emailType == PrizeConstants.EmailType.FisrtDayOnWeek1Trial) { nodeId = 12933; } else if (emailType == PrizeConstants.EmailType.NewYearEmailTrial) { nodeId = 12954; } else if (emailType == PrizeConstants.EmailType.EasterEmailTrial) { nodeId = 12940; } else if (emailType == PrizeConstants.EmailType.ChristmasEmailTrial) { nodeId = 12939; } else if (emailType == PrizeConstants.EmailType.BirthdayEmailTrial) { nodeId = 12938; } if (nodeId == 0) { return(false); } var node = new Node(nodeId); var templateNode = new Node(templateNodeId); string header = templateNode.GetProperty("templateheader").Value; string footer = templateNode.GetProperty("templateFooter").Value; string body = node.GetProperty("bodyContent").Value; string subject = emailSubject; if (node.GetProperty("subject") != null) { subject = node.GetProperty("subject").Value; } if (additionalContents.Count > 0) { body = body.Replace("[name]", additionalContents[0]); } if (emailType == PrizeConstants.EmailType.WelcomeEmail) { body = body.Replace("[username]", additionalContents[1]); } if (emailType == PrizeConstants.EmailType.OneDaysPrior2Week4Normal || emailType == PrizeConstants.EmailType.OneDaysPrior2Week4Vegan || emailType == PrizeConstants.EmailType.OneDaysPrior2Week4Lactose || emailType == PrizeConstants.EmailType.OneDaysPrior2Week11) { body = body.Replace("[calories]", additionalContents[1]); string[] sMealValue = additionalContents[2].Split(';'); body = body.Replace("[protein]", sMealValue[0]); if (sMealValue.Length > 1) { body = body.Replace("[proteinpercentage]", sMealValue[1]); } sMealValue = additionalContents[3].Split(';'); body = body.Replace("[carb]", sMealValue[0]); if (sMealValue.Length > 1) { body = body.Replace("[carbpercentage]", sMealValue[1]); } sMealValue = additionalContents[4].Split(';'); body = body.Replace("[fat]", sMealValue[0]); if (sMealValue.Length > 1) { body = body.Replace("[fatpercentage]", sMealValue[1]); } } body = body.Replace("/login", "https://diypt.com.au/login/"); body = body.Replace("/my-account/", "https://diypt.com.au/my-account/"); body = body.Replace("/continueplan", "https://diypt.com.au/continueplan"); body = body.Replace("/revitalise-me", "https://diypt.com.au/revitalise-me"); try { body = body.Replace("viewonlineurl", "https://diypt.com.au" + node.NiceUrl); } catch { //Do nothing /* Known issue in Umbraco where NiceUrl fails */ body = body.Replace("viewonlineurl", "#"); } /*body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/"); * body = body.Replace("/login", "http://diypt.com.au/login/");*/ PrizeEmail.SendEmail(email, subject, (header + body + footer).Replace("/images/", "https://diypt.com.au/images/")); return(true); }