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