SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
HTML5 Tutorials and HTML5 Code Samples and HTML component examples for Web Developers




How to customize MailTo for Multiple Recipients, Subject and Body in HTML codes with samples

HTML developers can use MailTo in your HTML documents to support customized automatic emails from your web site. This HTML tutorial shows how to build HTML links to open email client applications automatically with predefined recepients and subject and body content.

By using the MailTo in your href links in HTML files, you can manage multiple recipients in a semicolons seperated format. You can also set a default subject field text for the email. Also it is possible to set the Copy To or the CC field values by typing the recipients for the CC field value. This capability is also valid for the Blind Copy To or the BCC field recipients.

The MailTo syntax also enables the HTML developer to set a default BODY text for the email object that is prepared using MailTo.

You can find a list of sample MailTo HTML codes to summarize the use of MailTo syntax with samples.

For more information on http://ftp.isi.edu/in-notes/rfc2368.txt about the syntax of 'mailto' URLs. RFC2368 defines the format of Uniform Resource Locators (URL) for designating electronic mail addresses

First sample uses the below code:

<a href="mailto:developer@kodyaz.com">MailTo:developer@kodyaz.com</a>

And seen on the HTML web page as below:

MailTo:developer@kodyaz.com

When the internet user who click on the above link will have the Outlook or the Email Client program that is set as default email program opened for a new message as shown below with only the To... field value is defined with one recipient.

mailto sample

 

Second sample illustrates a simple mailing but this time to multiple recipients in a semicolons seperated format in the HTML code. Some Client Email programs may also support comma delimited email address lists for declaring multiple recipients. But Microsoft Office Outlook does not recognize the comma seperated syntax for multiple emails.

MailTo:developer1@kodyaz.com;developer2@kodyaz.com

mailto sample with multiple recipients

You might have seen that some of the emails have been declared with in a new tag "To" in the hyperlink tag A. But this method is not supported with most of the email programs. And is not a good practise to place such a html code in your web pages.

If you also want to declare the Copy To or the CC field recipients, then use the below syntax for your HTML codes. It is just like adding a new query string parameter named "CC" to a URL

MailTo:developer1@kodyaz.com;developer2@kodyaz.com&cc=developer3@eralper.com

mailto sample with CC recipient

We can alter the above syntax in a similar way for Blind Copy To or the BCC field. This time our new query string parameter will be "BCC". The sample for the BCC can be build as follows:

MailTo:developer1@kodyaz.com;developer2@kodyaz.com&cc=developer3@eralper.com&bcc=developer4@eralper.com

mailto with bcc recipient

After dealing with the recipient declarations for our new mail message in the HTML codes, we can further customize the new mail object with defining the subject of the email as follows:

mailto:developer1@kodyaz.com&subject=Mail To Syntax with Samples

If above syntax fails to work on a Mac (as mentioned and the solution is also suggested by Ada), you can try below usage where the ampersand character is replaced with "?" question mark just like passing parameters to a URL address.

mailto:developer1@kodyaz.com?subject=Mail To Syntax with Samples

mailto-sample-with-subject-field

As you will guess BODY of the email can be customized in the HTML code by passing a new parameter named BODY in the query string of the email object with in the hyperlink href definition. Below is a  sample for a customized email with its body is defined in the html code.

mailto:developer1@kodyaz.com?subject=Mail To Syntax with Samples&body=Hi, in this article you will find samples about how to use MailTo in HTML

mailto with body field

If you want to customize the body with a little bit more for instance if you want to add new line characters in your email you can add "%0D%0A" string within your body text. You can place "%0D%0A" where you want to see the line breaks or the end of line in your message string. Also if you want you can replace the blank character or " " empty space character with "%20" and form your text values with "%20" instead of space characters. This way the space characters in the message texts are URL encoded with "%20".

mailto:developer1@kodyaz.com?subject=Mail To Syntax with Samples&body=Hi,%0AIn this article you will find samples about how to use MailTo in HTML

mailto with multiline body field

I hope the sample are helpful to summarize the use of the mailto in your html codes to design a URL for processing emails.



HTML5


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.