public ActionResult Responder(FaleConosco faleconosco) { if (ModelState.IsValid) { faleconosco.lida = 1; db.Entry(faleconosco).State = EntityState.Modified; faleconosco.dataResposta = DateTime.Now; faleconosco.assunto = ""; String body = System.IO.File.ReadAllText(Server.MapPath("~/ModelosEmail/modeloemail.asp")); var emailModel = new MailModel(); body = body.Replace("##nome##", faleconosco.nome); body = body.Replace("##mensagem##", faleconosco.mensagem); body = body.Replace("##resposta##", faleconosco.resposta); body = body.Replace("../", "http://" + Request.Url.Authority + "/"); body = body.Replace("##data##", DateTime.Now.ToString("dd/MM/yyyy")); emailModel.Body = body; emailModel.Subject = "RĂ¡dio CompanyName - Fale Conosco"; emailModel.To = faleconosco.email; emailModel.SendEmail(); db.SaveChanges(); GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, faleconosco.id); return(RedirectToAction("Index")); } return(View(faleconosco)); }
/// <summary> /// The resend email. /// </summary> /// <param name="emailHistoryId"> /// The email history id. /// </param> /// <returns> /// The <see cref="EmailHistoryDTO"/>. /// </returns> /// <exception cref="FaultException{T}"> /// Exception if sending failed /// </exception> public EmailHistoryDTO ResendEmail(int emailHistoryId) { var item = EmailHistoryModel.GetOneById(emailHistoryId).Value; if (item != null) { var cc = item.SentCc != null ? FormEmailList(item.SentCc) : new List <MailAddress>(); var bcc = item.SentBcc != null ? FormEmailList(item.SentBcc) : new List <MailAddress>(); MailModel.SendEmail( item.SentToName != null ? item.SentToName.Split(';').ToArray() : new string[] { }, item.SentTo != null ? item.SentTo.Split(';').ToArray() : new string[] { }, item.Subject, item.Body, item.SentFromName, item.SentFrom, null, cc, bcc); var newHistoryItem = new EmailHistoryDTO(item) { body = item.Body, date = DateTime.Now.ConvertToUnixTimestamp(), emailHistoryId = 0 }; return(this.SaveHistory(newHistoryItem)); } var error = new Error(Errors.CODE_ERRORTYPE_GENERIC_ERROR, ErrorsTexts.GetResultError_NotFound, "No item with such id found"); this.LogError("EmailService.Save", error); throw new FaultException <Error>(error, error.errorMessage); }