public IHttpActionResult SentTestEmail(ViewModel.tblSentEmail SentEmail) { try { ViewModel.tblSystemEmail objSysEmail = new ViewModel.tblSystemEmail(); DataSet dsSysTemEmail = BisSystemEmail.GetSystemEmailDataSetData(objSysEmail); JArray dsUser = AuUser.ReturnUser(SentEmail.IDLogUser); SentEmail.EmailFrom = dsSysTemEmail.ReturnDataSetField("Email"); SentEmail.SmtpAddress = dsSysTemEmail.ReturnDataSetField("SMTP_Address"); SentEmail.PortNumber = dsSysTemEmail.ReturnDataSetField("PortNumber").StringToInt(); SentEmail.IDSentEmail = Guid.NewGuid(); SentEmail.EmailStatus = "Successfull"; SentEmail.IDSender = dsUser[0]["IDUser"].ToString().StringToGuid(); SentEmail.SenderFirstName = ""; SentEmail.SenderLastName = ""; string NewsLetterStructure = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Templates\NewsLetterStructure.txt"); SentEmail.Body = NewsLetterStructure.Replace("@@Content", SentEmail.Body).Replace("@@EmailName", SentEmail.EmailTo).Replace("@@IDXContent", SentEmail.IDXRet.ToString()); MailMessage mail = new MailMessage(); mail.From = new MailAddress(SentEmail.EmailFrom, "Farbin"); mail.To.Add(SentEmail.EmailTo); mail.Subject = SentEmail.Subject; mail.Body = SentEmail.Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(SentEmail.SmtpAddress, dsSysTemEmail.ReturnDataSetField("PortNumber").StringToInt()); smtp.Credentials = new NetworkCredential(SentEmail.EmailFrom, dsSysTemEmail.ReturnDataSetField("Password")); smtp.EnableSsl = false; smtp.Send(mail); smtp.Dispose(); SentEmail.IDLogUser = null; bool ret = BisSentEmail.AddSentEmail(SentEmail); return(Ok(ret)); } catch (Exception ex) { return(NotFound()); } }
public JArray GetSystemEmailJsonData(ViewModel.tblSystemEmail SystemEmail) { return(sqlHelper.ReturnJsonData("sp_tblSystemEmail_GetData_json", SystemEmail)); }
public DataSet GetSystemEmailDataSetData(ViewModel.tblSystemEmail SystemEmail) { return(sqlHelper.returnDataSet("sp_tblSystemEmail_GetData_ds", SystemEmail)); }