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="mailto:someone@x.com?Subject=Some Topic&Body=This is the body">Send Email</a>
<a href="mailto:joe@x.com?Subject=Some Topic&CC=pete@x.com&BCC=john@x.com">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.
Character
|
Encoding
|
blank
|
%20
|
Question Mark
|
%3F
|
Ampersand
|
%27
|
Equals Sign
|
%3E
|
Line Break
|
%0D%0A
|
So, to include a line break in say the body of an email, try:
<a href="mailto:someone@x.com?Body=Line 1%0D%0ALine2">Send Email</a>
|