public async Task SendDeclinedEmailToEmployee(string employeeEmail) { string actualBody = String.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplates/DeclinedRequest.html"))) { actualBody = reader.ReadToEnd(); } Shared.SendGrid Email = new Shared.SendGrid(); Task <bool> t = Email.SendEMailAsync(employeeEmail, actualBody, "PTO Declined"); await t; }
public async Task SendEmailToApprover(string approverEmail) { string actualBody = String.Empty; using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplates/RequestForPTO.html"))) { actualBody = reader.ReadToEnd(); } Shared.SendGrid Email = new Shared.SendGrid(); Task <bool> t = Email.SendEMailAsync(approverEmail, actualBody, "PTO Requested"); await t; }
public async Task <ActionResult> ExcessRolloverEmail() { List <ReportingViewModel> ReportList; List <Task <bool> > taskList = new List <Task <bool> >(); string actualBody = ""; int success = 0, total = 0; if (!CurrentUser.IsAdmin) { throw new Exception("Unauthorized user access"); } ReportList = GetAllReportingModels(); foreach (var employee in ReportList) { using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailTemplates/ExcessRolloverNotice.html"))) { actualBody = reader.ReadToEnd(); } actualBody = actualBody.Replace("[USERNAME]", employee.DisplayName.ToString()); actualBody = actualBody.Replace("[HOURSOFEXCESSPTO]", employee.ExcessRolloverPTO.ToString()); Shared.SendGrid Email = new Shared.SendGrid(); Task <bool> t = Email.SendEMailAsync(employee.Email, actualBody, "Update on your current PTO"); taskList.Add(t); } foreach (var task in taskList) { if (await task) { success++; } total++; } return(Content(String.Format("Complete: {0}/{1} messages sent!", success, total))); }