Wednesday, November 03, 2010

Creating HTML Links with MailTo attribute

MailTo (read as "mail to") attribute is used for creating mailing links, i.e., after clicking this link the default e-mail sender/receiver of the operating system will open automatically with the recipent's e-mail address in the "Send to" box, ready for sending an e-mail to whom the creator of the webpage chooses.


General syntax/format of the HTML link with mailto attribute is
<a href="mailto:[e-mail address]">[Link Text]</a>


Replace [e-mail address] with the recipent's e-mail address, the person you the creator of the document wants to send an e-mail to when some person clicks on the link. [Link Text] can be replaced by the text link to appear, like "click here to mail me", etc.

For example:


Input:


<a href="mailto:someone@example.com">Click Here to mail me</a>

Output:

If you want to add a subject to the automatically opened e-mail, then simply add ?subject=[subject] after the e-mail of the recipent, enclosed in the quotation marks, i.e.,

<a href="mailto:someone@example.com?subject=Hello%20Sir">[Link Text]</a>


Here the subject is "Hello Sir" and "%20" is used for a blank space.


For example:

Input:

<a href="mailto:someone@example.com?subject=Hello%20Sir.%20How%20are%20you?">Click Here to mail me</a>

Output:

Click Here to mail me

"%20" can be used any number of times to generate a blank space.

No comments:

Post a Comment


Ali Khan Blogs is a SEO Blogger Blog about Blogging and SEO Tips and Tricks for New Bloggers