I have an ASP.NET button. If the user clicks this button, then it calls mailto
, which opens the outlook mail window. I have done this by adding the following line into the ASP.net button control tag.
window.open('mailto: abc def<[email protected]>?subject= exSub &body= exBody');
Now I want to set the body text (in the above example it is exBody) dynamically in my code behind method. How can I do that?
Bind it to a page property, and use the property to construct the mailto attribute (URL-encoded):
<asp:Button RunAt = "Server"
onclick = <%#
"window.open('mailto: abc def<[email protected]>?subject= exSub &body="
+ Server.UrlEncode(MailToBody ?? "") + "');"
%>
/>
Then set the MailToBody
property from your code-behind as needed.