Send E-mail from a web page with the MailTo command

To send email from a hyperlink in HTML or the System.Web.UI.Controls.Hyperlink control in ASP.NET, use the MailTo command. When your web page is rendered, it will contain a hyperlink which, when clicked, will open the user's default email application.

The syntax of the MailTo command is straight forward:

   <a href="mailto:">Send Email</a>

In the case of ASP.NET's Hyperlink control, set its NavigateUrl property to the above.

To specify a receipient use this syntax:

    <a href="mailto:Someone@someplace">Send Email</a>

Additional options can be specified by including certain keywords. The first option must begin with a question mark. Subsequent options begin with an ampersand. Options can be mixed and matched. See the following examples:

    <a href=" Topic&Body=This is the body">Send Email</a>

    <a href=" Topic&">Send Email</a>

Because the question mark and ampersand are special characters, you canot include them in the MailTo command. Instead, you have to encode them specially. This applies to other characters as well.





Question Mark




Equals Sign


Line Break


So, to include a line break in say the body of an email, try:

    <a href=" 1%0D%0ALine2">Send Email</a>

About TheScarms
About TheScarms

Sample code
version info

If you use this code, please mention ""

Email this page

© Copyright 2024 TheScarms
Goto top of page