Of course, it won't but It would work like this
public void sendmail(string toAddr)
{
string to = toAddr;
string from = "xyz@gmail.com";
MailMessage message = new MailMessage(from,to);
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
}
protected void sendBtn_Click(object sender, EventArgs e)
{
sendMail(TextBox2.Text);
}
Parameters must be passed as an arguments to the function -
basic rule of function/method.
-KR