public static void NotifyOnAuditCreate(decimal auditId, decimal personId) { var entities = new PSsqmEntities(); decimal companyId = SessionManager.UserContext.HRLocation.Company.COMPANY_ID; decimal busOrgId = SessionManager.UserContext.HRLocation.BusinessOrg.BUS_ORG_ID; var emailIds = new HashSet <decimal>(); AUDIT audit = EHSAuditMgr.SelectAuditById(entities, auditId); string auditType = EHSAuditMgr.SelectAuditTypeByAuditId(auditId); emailIds.Add((decimal)audit.AUDIT_PERSON); if (emailIds.Count > 0) { string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE; if (string.IsNullOrEmpty(appUrl)) { appUrl = "the website"; } string emailSubject = "Audit Created: " + auditType; string emailBody = "A new audit has been created:<br/>" + "<br/>" + auditType + "<br/>" + "<br/>" + "Please log in to " + appUrl + auditPath + " to view the audit."; foreach (decimal eid in emailIds) { string emailAddress = (from p in entities.PERSON where p.PERSON_ID == eid select p.EMAIL).FirstOrDefault(); Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "", "web")); thread.IsBackground = true; thread.Start(); //WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, ""); } } }