You can use jQuery to intercept the click and construct an ajax request that includes the html of your choice. Accept the html as a string argument with a matching name. Then use the smtp client to forward it to the address of your choice.
<script>
$(document).ready(function () {
$(document).on("click", "#button1", {}, function (event) {
event.preventDefault();
var x = $("#mydiv").html();
var options = {
url: "your url",
method: "POST",
data: {
data1: x
}
};
var req = $.ajax(options);
req.done(function (resp) {
alert("Email sent");
});
});
});
</script>
<div id="mydiv">
<div>
<a id="button1">Click Here</a>
</div>
</div>
public IActionResult TestAction(string data1)
{
SmtpClient client = new SmtpClient("smtp_server");
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("username", "password");
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("test@test.com");
mailMessage.To.Add("test@test.com");
mailMessage.Body = data1;
mailMessage.Subject = "subject";
client.Send(mailMessage);
return null;//or whatever you want
}