This question is an exact duplicate of:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication5;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Net.Mail;
namespace WebApplication5 {
public partial class SendMail : System.Web.UI.Page {
public SendMail()
{
mailMessage mail = new MailMessage();
mail.To.Add(txtTo.Text);
mail.From = new MailAddress("salahuddin20364@gmail.com");
mail.Subject = "Email using Gmail";
string Body = txtmessage.Text;
mail.Body = Body;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("salahuddin20364@gmail.com", "sagdgd!");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
protected void Bttn_Send_Click(object sender, EventArgs e)
{
SendMail();
}
} }
Error 1 The name 'txtTo' does not exist in the current context
Error 2 The name 'txtmessage' does not exist in the current context
How to declear txtTo & txtmessage , could anyone help me please?