How to customize MailTo for Multiple Recipients, Subject and Body in HTML codes with samples
You can use MailTo in your HTML documents to support customized automatic emails from your web site.
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:
And seen on the HTML web page as below:
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.
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.
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 codes.
It is just like adding a new query string parameter named "CC" to a URL
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:
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:email@example.com&subject=Mail To Syntax with Samples
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:firstname.lastname@example.org&subject=Mail To Syntax with Samples&body=Hi, in this article you will find samples about how to use MailTo in HTML
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:email@example.com&subject=Mail To Syntax with Samples&body=Hi,%0AIn this article you will find samples about how to use MailTo in HTML
I hope the sample are helpful to summarize the use of the mailto in your html codes to design a URL for processing emails.