private void ProcessTaskAssigned(int taskID, int modifierID) { TasksViewItem task = TasksView.GetTasksViewItem(LoginUser, taskID); try { User modifier = Users.GetUser(LoginUser, modifierID); if (task == null) { Logs.WriteEvent("Unable to find Task, TaskID: " + taskID.ToString()); return; } if (modifier == null) { Logs.WriteEvent("Unable to find Modifying User, UserID: " + modifierID.ToString()); return; } if (task.UserID == null) { Logs.WriteEvent("Assigned Task User is null"); return; } Organization taskOrganization = Organizations.GetOrganization(LoginUser, task.OrganizationID); if (taskOrganization == null) { Logs.WriteEvent("Task's Organization IS NULL!!!!"); return; } User owner = Users.GetUser(LoginUser, (int)task.UserID); if (owner.UserID == modifier.UserID) { Logs.WriteEvent("Modifier and Owner are the same person."); return; } if (Emails.IsEmailDisabled(LoginUser, owner.UserID, "Tasks")) { return; } MailMessage message = EmailTemplates.GetTaskAssigned(LoginUser, UsersView.GetUsersViewItem(LoginUser, modifierID), UsersView.GetUsersViewItem(LoginUser, (int)task.UserID), task); message.To.Add(GetMailAddress(owner.Email, owner.FirstLastName)); //message.Subject = message.Subject + " [pvt]"; EmailTemplates.ReplaceMailAddressParameters(message); String description = String.Format("Task assigned notification sent to {0} for Task {1}", message.To.ToString(), task.Name); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tasks, task.TaskID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, (int)task.UserID, description); //string emailReplyToAddress = GetEmailReplyToAddress(LoginUser, ticket); //AddMessage(taskOrganization, "Ticket Update Request [" + ticket.TicketNumber.ToString() + "]", message, emailReplyToAddress); Emails.AddEmail(LoginUser, task.OrganizationID, null, message.Subject, message); Logs.WriteEvent("Message queued"); } catch (Exception ex) { Logs.WriteEvent("Error with ProcessTaskAssigned"); Logs.WriteException(ex); ExceptionLogs.LogException(LoginUser, ex, "ProcessTaskModified", task.Row); } }