public ActionResult SendMessageFromManagerToResident([Bind(Include = "Id,Resident,BuildingName,Unit,Subject,Body")] Messages messages) { if (ModelState.IsValid) { db.Messages.Add(messages); db.SaveChanges(); string residentEmail = null; var residentEmailQuery = from rm in db.Residents where (rm.Name == messages.Resident) select rm.EmailAddress; foreach (string result in residentEmailQuery) { residentEmail = result; } MailGun managerMessageToResident = new MailGun(); managerMessageToResident.SendFromMgrToResident(residentEmail, messages.Subject, messages.Body, messages.Resident); return(RedirectToAction("MessageSuccess")); } return(View(messages)); }