public async Task<ActionResult> CreateEvent(CreateEventViewModel eventObject)
        {
            var model = eventObject;

            // Create EWS Appointment

            var request = new CreateAppointmentRequest
            {
                Body = "Created From Web App",
                End = DateTime.Parse(eventObject.Event.end).ToString(),
                Start = DateTime.Parse(eventObject.Event.start).ToString(),
                Location = "Web",
                Subject = eventObject.Event.title,

                Recipients = eventObject.Users

            };
            var resp = await _client.CreateAppointment(request);

            // Send Emails
            var emailRequest = new SendEmailRequest
            {
                Recipients = eventObject.Users,
                Body = "Automated Email After Appointment Creation",
                FileAttachments = new List<string>(),
                Subject = "Automated Email After Appointment Creation"
            };
            var sendEmailResponse = await _client.SendEmail(emailRequest);

            return RedirectToAction("Index");
        }
        public void SendEmail()
        {
            var rep = new EWSIntegrationClient();

            var request = new SendEmailRequest
            {
                Body = "Test Email from MVC App",
                Recipients = new List<string> { "*****@*****.**"  },
                Subject = "Test Email from MVC App Unit Test",
            };

            var result = rep.SendEmail(request).Result;

            Assert.IsNotNull(result.Recipients);
        }
        public async Task<SendEmailResponse> SendEmail(SendEmailRequest request)
        {
            var response = new SendEmailResponse();
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(_url);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage resp = await client.PostAsJsonAsync("/api/email", request);
                if (resp.IsSuccessStatusCode)
                {
                    response = await resp.Content.ReadAsAsync<SendEmailResponse>();

                    return response;
                }
            }

            return response;
        }