private void UploadReferences() { FileType referenceFileType = FileTypeBLL.GetByName(STR_LetterOfRec); if (fileUploadReference.HasFile) { if (FileBLL.IsPostedFilePDF(fileUploadReference.PostedFile)) { File file = new File(); file.FileName = fileUploadReference.FileName; file.FileType = referenceFileType; using (var ts = new TransactionScope()) { FileBLL.EnsurePersistent(file, true); ts.CommitTransaction(); } if (ValidateBO <File> .isValid(file)) { SaveReferenceWithWatermark(fileUploadReference, file.ID.ToString()); currentReference.ReferenceFile = file; using (var ts = new TransactionScope()) { ReferenceBLL.EnsurePersistent(currentReference); ts.CommitTransaction(); } //Send confirmation email after success -- if there are errors, ignore try { System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient(); string subject = "Reference Upload Confirmation"; StringBuilder bodyText = new StringBuilder(); bodyText.AppendFormat("Your reference letter for {0}, who applied to the {1} position at the University of California, has been successfully received.", currentReference.AssociatedApplication.AssociatedProfile.FullName, currentReference.AssociatedApplication.AppliedPosition.PositionTitle); bodyText.AppendFormat(" We appreciate your comments.", currentReference.AssociatedApplication.AssociatedProfile.LastName); MailMessage message = new MailMessage(currentReference.AssociatedApplication.AppliedPosition.HREmail, currentReference.Email, subject, bodyText.ToString()); message.IsBodyHtml = true; mail.Send(message); //Send the message } catch (Exception) { } //Continue on failure Response.Redirect(UploadReferenceSuccessURL); } else { lblUploadStatus.Text = "There was an unexpected error uploading your file"; } } else { lblUploadStatus.Text = "Please upload a file in PDF format"; } } }