You are on page 1of 2

///ni dung th: string Chuoi = ""; Chuoi += "Tn khc hng: " + txthoten.

Text; Chuoi += "<br />in thoi: " + txtsodienthoai.Text; Chuoi += "<br />a ch: " + txtdiachi.Text +"-"+txttinh.Text; Chuoi += "<br />Email: " + txtemail.Text; Chuoi += "<br />Danh sch sn phm: "; Chuoi += "<br /><div></div>"; Chuoi += "<table cellpadding=\"0px\" cellspacing=\"0px\" width=\"500px\" border=\"1\">\n"; Chuoi += "<tr>\n"; Chuoi += "<th width=\"200px\">Tn sn phm</th>\n"; Chuoi += "<th width=\"100px\">Gi</th>\n"; Chuoi += "<th width=\"100px\">S lng</th>\n"; Chuoi += "<th width=\"100px\">Thnh tin</th>\n"; Chuoi += "</tr>\n"; for (int i = 0; i < dt.Rows.Count; i++) { List<Product> listpro = ProductService.Product_GetById(dt.Rows[i]["ProductID"].ToString()); Chuoi += "<tr>\n"; Chuoi += "<td>" + listpro[0].Name + "</td>\n"; Chuoi += "<td align=\"center\">" + Format_Price(dt.Rows[i]["Price"].ToString()) + "</td>\n"; Chuoi += "<td align=\"center\">" + Format_Price(dt.Rows[i]["Quantity"].ToString()) + "</td>\n"; Chuoi += "<td align=\"center\">" + Format_Price(dt.Rows[i]["Total"].ToString()) + " VN</td>\n"; Chuoi += "</tr>\n"; tongtien += Double.Parse(dt.Rows[i]["Total"].ToString()); Data.tbBilldetail objbilldetail = new tbBilldetail(); objbilldetail.bilid = billid; objbilldetail.proid = dt.Rows[i]["ProductID"].ToString(); objbilldetail.sizeid = "0"; objbilldetail.colorid = "0"; objbilldetail.quantity = dt.Rows[i]["Quantity"].ToString(); objbilldetail.bilprice = dt.Rows[i]["Price"].ToString(); objbilldetail.bilpricevnd = dt.Rows[i]["Price"].ToString(); objbilldetail.bilmoney = dt.Rows[i]["Total"].ToString(); objbilldetail.Billlocation = ""; if (muachung != "") { objbilldetail.status = "2"; } else { objbilldetail.status = "1"; } tbBilldetailService.tbBilldetail_Insert(objbilldetail); } Chuoi += "</table>\n"; Chuoi += "</div>\n"; Chuoi += "</ br>"; Chuoi += "</ br>"; Chuoi += "<div>Tng tin: " + Format_Price(tongtien.ToString()) + " VN"; Chuoi += "</ br>"; Chuoi += "</ br>";

Chuoi += "<p> Cm n bn mua hng ti <a href=\"#\">NUOCHOAMYPHAM.VN</a>, mi thc mc xin gi v hm th: <a href=\"mailto:machongtuantk73@gmail.com\">h tr mua hng!</p>";

#region[Sendmail] System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); List<Config> list = ConfigService.Config_GetByAll("vi"); string mailto = list[0].Mail_Noreply; string pas = list[0].Mail_Password; string host = list[0].Mail_Smtp; int port = 0; if (list[0].Mail_Port.Length > 0) { port = int.Parse(list[0].Mail_Port); } else { port = 587; } host = "smtp.gmail.com"; mailMessage.From = (new MailAddress(txtemail.Text, "H tr t hng", System.Text.Encoding.UTF8)); mailMessage.To.Add(txtemail.Text); mailMessage.Bcc.Add(mailto); //mailMessage.Bcc.Add(mailto); mailMessage.Subject = "NUOCHOAMYPHAM.VN-Thng tin t hng ca "+txthoten.Text.Trim().ToUpper(); mailMessage.SubjectEncoding = System.Text.Encoding.UTF8; mailMessage.Body = Chuoi; mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = System.Text.Encoding.UTF8; System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential(); mailAuthentication.UserName = list[0].Mail_Noreply; mailAuthentication.Password = list[0].Mail_Password; //System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("" + host + "", post); System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); mailClient.EnableSsl = true; mailClient.UseDefaultCredentials = false; mailClient.Credentials = mailAuthentication; try { mailClient.Send(mailMessage); Common.WebMsgBox.Show("Bn gi thnh cng !!"); //return; } catch { Common.WebMsgBox.Show("H thng nhn t hng ca bn nhng c li xy ra khi gi mail cho ban qun tr !!"); return; } #endregion

You might also like