public async Task <ActionResult> InquiryForm(InquiryFormModel model) { if (ModelState.IsValid) { var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); // replace with valid value message.From = new MailAddress("*****@*****.**"); // replace with valid value message.Subject = "Your email subject"; message.Body = string.Format(body, model.FromName, model.FromEmail, model.Message); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", // replace with valid value Password = "******" // replace with valid value }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; await smtp.SendMailAsync(message); return(RedirectToAction("Sent")); } } return(View(model)); }
///詢價單管理頁面 public ActionResult InquiryMainPage(string id) { log.Info("queryInquiry by projectID=" + id + ",status=" + Request["status"]); InquiryFormModel formData = new InquiryFormModel(); if (null != id && id != "") { ViewBag.projectid = id; TND_PROJECT p = service.getProjectById(id); ViewBag.projectName = p.PROJECT_NAME; formData.tndTemplateProjectForm = service.getFormTemplateByProject(id); formData.tndProjectFormFromSupplier = service.getFormByProject(id, Request["status"]); } return(View(formData)); }