You can create a class. In that class you can have a method called SendEmail with some parameter like
public class Email
{
public Email()
{
//
// TODO: Add constructor logic here
//
}
public void SendEmail(string receiverEmail, string subject, string body)
{
//Write some code
}
}
After that create an object of that class and call that method in Button Onclick Event
HTML
<asp:Button Text="Send Email" OnClick="SendEmail" runat="server" />
Button Event
protected void SendEmail(object sender, EventArgs e)
{
Email email = new Email();
email.SendEmail("test@test.com", "subject", "body");
}