public ActionResult Send(FormCollection collection) { try { string fileid = collection.GetValue("FieldId").AttemptedValue; int fileId = Convert.ToInt32(fileid); PubSubRepository psr = new PubSubRepository(); FilesRepository fr = new FilesRepository(); Models.File f = fr.GetFile(fileId); FileSendTo fst = new FileSendTo(); string email = collection.GetValue("Email").AttemptedValue; string message = collection.GetValue("Message").AttemptedValue; fst.Link = f.Link; fst.Name = f.Name; fst.OwnerFk = f.OwnerFk; fst.Message = message; fst.Email = email; psr.AddToEmailQueue(fst); psr.DownloadEmailFromQueueAndSend(); new LoggingRepository().Logging("File: " + f.Name + " Shared With: " + email + " At: " + DateTime.Now); return(RedirectToAction("Index")); } catch (Exception ex) { new LoggingRepository().ErrorLogging(ex); } return(View()); }