public void sendmessage1() { connection(); SqlCommand com = new SqlCommand("YellowMailSend", con); com.Parameters.AddWithValue("@req_id", Label1.Text.ToString()); ; com.CommandType = CommandType.StoredProcedure; sqlda = new SqlDataAdapter(com); dt.Clear(); sqlda.Fill(dt); if (dt.Rows.Count > 0) { //string filepath = Server.MapPath("MailForm.htm"); string filepath = Server.MapPath("~/MailTest.htm"); StreamReader reader = new StreamReader(filepath); Message1 = reader.ReadToEnd(); Message1 = Message1.Replace("@Requ", dt.Rows[0]["REQ_ID"].ToString()); MailMessage mailObj = new MailMessage( lblfrom.Text, lbltocanteen.Text, lblSubject.Text, Message1); SmtpClient SMTPServer = new SmtpClient("500.500.500.500"); try { SMTPServer.Send(mailObj); } catch (Exception ex) { Label1.Text = ex.ToString(); } } |