public void send(C回覆 y) { //Jouta官方帳號 string gmail_account = "*****@*****.**"; string gmail_password = "******"; string gmail_mail = "*****@*****.**"; var fromEmail = new MailAddress(gmail_mail, "Jouta服務團隊"); var toEmail = new MailAddress(y.f電子郵件); string body = "你好," + " " + y.f聯絡人 + " " + "Jouta團隊已收到您的意見:" + "<br/>" + "<br/>" + y.f標題 + "<br/>" + "<br/>" + y.f意見 + "<br/>" + "<br/>" + "在此向您說明:" + "<br/>" + "<br/>" + y.f回覆 + "<br/>" + "<br/>" + "<br/>" + "<br/>" + "如有任何問題,歡迎隨時與我們聯繫,謝謝"; SmtpClient smtpServer = new SmtpClient("smtp.gmail.com"); smtpServer.Port = 587; smtpServer.Credentials = new System.Net.NetworkCredential(gmail_account, gmail_password); //開啟SSL smtpServer.EnableSsl = true; MailMessage mail = new MailMessage(); //設定來源信箱 mail.From = new MailAddress(gmail_mail); //設定收信者信箱 mail.To.Add(toEmail); //主旨 mail.Subject = "Jouta意見回覆"; //內容 mail.Body = body; //設定信箱內容為HTML格式 mail.IsBodyHtml = true; smtpServer.Send(mail); }
public ActionResult r回覆(C回覆 y, tComment p) { send(y); //ViewBag.kk = "傳送成功"; dbJoutaEntities db = new dbJoutaEntities(); tComment A = db.tComment.FirstOrDefault(m => m.fID == p.fID); if (A != null) { A.f意見狀態 = "已回覆"; db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult New(C回覆 y) { dbJoutaEntities db = new dbJoutaEntities(); tComment x = new tComment(); x.f標題 = Request.Form["f標題"]; x.f意見 = Request.Form["f意見"]; x.f性別 = Request.Form["f性別"]; x.f意見類型 = Request.Form["f意見類型"]; x.f聯絡人 = Request.Form["f聯絡人"]; x.f電子郵件 = Request.Form["f電子郵件"]; x.f電話 = Request.Form["f電話"]; x.f意見時間 = DateTime.Now.ToString(); x.f意見狀態 = "未回覆"; db.tComment.Add(x); db.SaveChanges(); string message = "傳送成功"; ViewBag.ll = message; return(View()); }