public virtual Task <HttpStatusCode> SendEmailAddNew(EventSubmission eventSubmission) { var messageSubject = $"[Event date] - {eventSubmission.EventDate.Value.ToString("d MMMM yyyy")}, [Event] - {eventSubmission.Title}"; _logger.LogInformation("Sending event submission form email"); var attachments = new List <IFormFile>(); if (eventSubmission.Image != null) { attachments.Add(eventSubmission.Image); } if (eventSubmission.Attachment != null) { attachments.Add(eventSubmission.Attachment); } var imagePath = FileHelper.GetFileNameFromPath(eventSubmission.Image); var attachmentPath = FileHelper.GetFileNameFromPath(eventSubmission.Attachment); var emailBody = new EventAdd { Title = eventSubmission.Title, EventDate = eventSubmission.EventDate.HasValue ? ((DateTime)eventSubmission.EventDate).ToString("dddd dd MMMM yyyy") : "-", EndDate = eventSubmission.EndDate.HasValue ? ((DateTime)eventSubmission.EndDate).ToString("dddd dd MMMM yyyy") : "-", StartTime = eventSubmission.StartTime.HasValue ? ((DateTime)eventSubmission.StartTime).ToString("HH:mm") : "-", EndTime = eventSubmission.EndTime.HasValue ? ((DateTime)eventSubmission.EndTime).ToString("HH:mm") : "-", Frequency = !string.IsNullOrEmpty(eventSubmission.Frequency) ? eventSubmission.Frequency : "-", Fee = !string.IsNullOrEmpty(eventSubmission.Fee) ? eventSubmission.Fee : "-", Location = !string.IsNullOrEmpty(eventSubmission.Location) ? eventSubmission.Location : "-", SubmittedBy = !string.IsNullOrEmpty(eventSubmission.SubmittedBy) ? eventSubmission.SubmittedBy : "-", Description = !string.IsNullOrEmpty(eventSubmission.Description) ? eventSubmission.Description : "-", ImagePath = !string.IsNullOrEmpty(imagePath) ? imagePath : "-", AttachmentPath = !string.IsNullOrEmpty(attachmentPath) ? attachmentPath : "-", SubmitterEmail = !string.IsNullOrEmpty(eventSubmission.SubmitterEmail) ? eventSubmission.SubmitterEmail : "-", Categories = eventSubmission.CategoriesList, GroupName = string.IsNullOrEmpty(eventSubmission.GroupName) ? string.Empty : $"Group name: {eventSubmission.GroupName}", Occurrences = eventSubmission.Occurrences == 0 ? string.Empty : $"(occurs {eventSubmission.Occurrences} times)", }; return(_emailClient.SendEmailToService(new EmailMessage(messageSubject, _emailClient.GenerateEmailBodyFromHtml(emailBody), _fromEmail, _configuration.GetEventSubmissionEmail(_businessId.ToString()).ToString(), eventSubmission.SubmitterEmail, attachments))); }