protected void uiLinkButtonSubmit_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(Request.QueryString["TID"].ToString()); DBLayer db = new DBLayer(); DataSet ds = new DataSet(); ds = db.GetTourismlistContent(id); MailMessage msg = new MailMessage(); DataSet to = db.GetAllMails(); foreach (DataRow item in to.Tables[0].Rows) { msg.To.Add(item["Email"].ToString()); } //msg.To.Add("*****@*****.**"); msg.From = new MailAddress("*****@*****.**"); //msg.From = new MailAddress("*****@*****.**"); msg.Subject = " Email from booking page"; msg.IsBodyHtml = true; msg.BodyEncoding = System.Text.Encoding.Unicode; msg.Body = " الإسم : " + uiDropDownListTitle.Text + " " + uiTextBoxName.Text; msg.Body += "<br/> البريد الإلكترونى : " + uiTextBoxEmail.Text; msg.Body += "<br/> الشارع : " + uiTextBoxStreet.Text; msg.Body += "<br/> المدينة : " + uiTextBoxCity.Text; msg.Body += "<br/> الرقم البريدى : " + uiTextBoxPostalCode.Text; msg.Body += "<br/> البلد : " + uiTextBoxCountry.Text; msg.Body += "<br/> التليفون : " + uiTextBoxTelephone.Text; msg.Body += "<br/> الموبايل : " + uiTextBoxMobile.Text; msg.Body += "<br/> إسم الرحلة : " + ds.Tables[0].Rows[0]["Title"].ToString(); msg.Body += "<br/> تفاصيل الرحلة : " + Server.HtmlDecode(ds.Tables[0].Rows[0]["Content"].ToString()); msg.Body += "<br/> الرابط على الموقع : " + Request.Url; SmtpClient client = new SmtpClient("mail.obtravel-eg.com", 25); //SmtpClient client = new SmtpClient("smtp.gmail.com", 587); //client.EnableSsl = true; client.UseDefaultCredentials = false; //client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "obtravelmail"); //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "********"); client.Send(msg); uiLabelMessage.Visible = true; } catch (Exception ex) { uiLabelMessage.Visible = true; uiLabelMessage.Text = ex.Message; } }
private void BindData() { DBLayer db = new DBLayer(); DataSet ds = new DataSet(); ds = db.GetAllMails(); uiGridViewNews.DataSource = ds; uiGridViewNews.DataBind(); }