Search Amazon:

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>
Sign In
  User Id 
  Password 


Submit Your Own Code and Articles




About TheScarms
About TheScarms

Ask me your programming questions

I read every email and answer all I can.

User Feedback: Be the first to add a comment! Items to Show:     

     
You must log in to post feedback.
Comment:    
 

If you use this code, please mention "www.TheScarms.com"

Email this page


TheScarms AppSentinel lets you securely copy protect and create evaluation versions of your software

TheScarms(tm) AppSentinel lets you quickly and easily create evaluation versions of your software and stop unauthorized copying and unregistered use of your programs!

Get your free
trial copy today!


      The World's Number 1 Web Host

© Copyright 2008 TheScarms