public void sendEmailThread() { var adjusterCount = 0; var supervisorCount = 0; RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager(); RuleException RuleExceptionObj = new RuleException(); List<RuleException> RuleExceptionArr = new List<RuleException>(); Globals gvGet = Globals.Instance(); int clientID = Convert.ToInt32(gvGet.getClientId()); RuleExceptionArr = RuleExceptionManagerObj.GetAllException(clientID); for (var i = 0; i < RuleExceptionArr.Count; i++) { int businessRuleId = Convert.ToInt32(RuleExceptionArr[i].BusinessRuleID); if (checkAdjusterSendMail(businessRuleId)) { adjusterCount = adjusterCount + 1; } if (checkSupervisorSendMail(businessRuleId)) { supervisorCount = supervisorCount + 1; } } int[] exceptionListAdjuster = new int[adjusterCount]; int[] formerExceptionListAdjuster = gvGet.getExceptionListAdjuster(); int[] exceptionListSupervisor = new int[supervisorCount]; int[] formerExceptionSupervisor = gvGet.getExceptionListSupervisor(); var j = 0; var k = 0; for (var i = 0; i < RuleExceptionArr.Count; i++) { int businessRuleId = Convert.ToInt32(RuleExceptionArr[i].BusinessRuleID); int userId = Convert.ToInt32(RuleExceptionArr[i].UserID); int claimId = Convert.ToInt32(RuleExceptionArr[i].ObjectID); if (checkAdjusterSendMail(businessRuleId)) { exceptionListAdjuster[j] = RuleExceptionArr[i].RuleExceptionID; bool canAdd = true; for (var q = 0; q < formerExceptionListAdjuster.Length; q++) { if (RuleExceptionArr[i].RuleExceptionID == formerExceptionListAdjuster[q]) { canAdd = false; } } if (canAdd) { adjusterSendMail(businessRuleId, clientID, userId, claimId); } j = j + 1; } if (checkSupervisorSendMail(businessRuleId)) { exceptionListSupervisor[k] = RuleExceptionArr[i].RuleExceptionID; bool canAdd = true; for (var q = 0; q < formerExceptionSupervisor.Length; q++) { if (RuleExceptionArr[i].RuleExceptionID == formerExceptionSupervisor[q]) { canAdd = false; } } if (canAdd) { supervisorSendMail(businessRuleId, clientID, userId, claimId); } k = k + 1; } } gvGet.setExceptionListAdjuster(exceptionListAdjuster); gvGet.setExceptionListSupervisor(exceptionListSupervisor); }