public void DistributeReminder(bool sendCalendar = false) { var recipients = context.Users.Where(t => t.IsActive == true && t.IsDeleted != true && t.IsDraft == false && t.Email != null).Select(t => t.Email).ToArray(); if (recipients.Length <= 0) { return; } var date = DateTime.Today.Date; var reminders = GetReminders(date); var subject = $"App Reminders {date.ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID"))}"; var body = CreateBody(reminders); ICSFileModel icsFileModel = new ICSFileModel() { Location = "Location", Subject = subject, Description = subject, StartDate = date.ChangeTime(16, 0, 0, 0), EndDate = date.ChangeTime(8, 0, 0, 0), IcsGuid = Guid.NewGuid().ToString(), Sequence = 1.ToString(), Method = "REQUEST" }; if (sendCalendar) { _emailSvc.SendEmailICS(recipients, subject, body, icsFileModel); } else { _emailSvc.SendEmailOnly(recipients, subject, body); } try { var log = new ActivityLog(); log.Action = "Distribute Reminder"; log.Url = ""; log.IPAddress = ""; log.HostName = ""; log.Modul = ""; log.Username = "******"; log.CreatedDate = DateTime.Now; log.Data = "Distribute Reminder " + DateTime.Now.ToString("yyyy MMM dd HH:mm:ss"); context.ActivityLogs.Add(log); context.SaveChanges(); } catch (Exception) { } }