public static int SendMail(EmailContracts objEmailContracts) { var _objMailMessage = new MailMessage(); try { if (objEmailContracts != null) { if (string.IsNullOrEmpty(objEmailContracts.emailFrom)) { return(2); } if (string.IsNullOrEmpty(objEmailContracts.emailTo)) { return(3); } var _mailAddress = new MailAddress(objEmailContracts.emailFrom); _objMailMessage.From = _mailAddress; _objMailMessage.To.Add(objEmailContracts.emailTo); if (!string.IsNullOrEmpty(objEmailContracts.emailCc)) { _objMailMessage.CC.Add(objEmailContracts.emailCc); } if (!string.IsNullOrEmpty(objEmailContracts.emailBcc)) { _objMailMessage.Bcc.Add(objEmailContracts.emailBcc); } _objMailMessage.Subject = !string.IsNullOrEmpty(objEmailContracts.emailSubject) ? objEmailContracts.emailSubject : "No Subject"; _objMailMessage.Body = !string.IsNullOrEmpty(objEmailContracts.emailBody) ? objEmailContracts.emailBody : "N/A"; if (objEmailContracts.hasAttachement) { var _attachement = new Attachment(new MemoryStream(objEmailContracts.attachement), objEmailContracts.attachmentName, objEmailContracts.attachmentType); _objMailMessage.Attachments.Add(_attachement); } _objMailMessage.IsBodyHtml = objEmailContracts.isBodyHtml; var smtpclientDetails = new SmtpClient(ConfigurationWrapper.StringSettings(ConfigKey.SmtpHost)); var netWorkCredential = new NetworkCredential(ConfigurationWrapper.StringSettings(ConfigKey.SmtpUserName), ConfigurationWrapper.StringSettings(ConfigKey.SmtpPassword)); smtpclientDetails.Port = ConfigurationWrapper.IntegerSettings(ConfigKey.SmtpPort); smtpclientDetails.Credentials = netWorkCredential; smtpclientDetails.SendAsync(_objMailMessage, string.Format("lms_{0}", DateTime.Now.ToString("MM-dd-yyyy"))); } return(1); } catch { return(0); } }
public List <DownLoadFileInformation> GetFiles(string dowloadType) { var filePath = dowloadType == "TEMPLATE" ? ConfigurationWrapper.StringSettings(ConfigKey.TemplateUploadPath) : ConfigurationWrapper.StringSettings(ConfigKey.PatientUploadPath); var lstFiles = new List <DownLoadFileInformation>(); var dirInfo = new DirectoryInfo(filePath); int i = 0; foreach (var item in dirInfo.GetFiles()) { lstFiles.Add(new DownLoadFileInformation() { FileId = i + 1, FileName = item.Name, FilePath = dirInfo.FullName + @"\" + item.Name }); i = i + 1; } return(lstFiles); }
public ActionResult Upload(HttpPostedFileBase uploadFile) { var uploadFor = Convert.ToString(Request["uploadfor"]); var filePath = uploadFor.ToUpper() == "TEMPLATE" ? ConfigurationWrapper.StringSettings(ConfigKey.TemplateUploadPath) : ConfigurationWrapper.StringSettings(ConfigKey.PatientUploadPath); if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var fullFilePath = Path.Combine(filePath, fileName); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } file.SaveAs(fullFilePath); } } return(RedirectToAction("UploadFile", new { message = "Uploaded" })); }