Sending email using the MAILTO protocol

Hyperlinking ››

Problem/Symptom

If you would like to offer the ability, to your end-users, to send an email from within a ToolBook application (or DHTML exported book), there are a variety of ways to accomplish this.


Resolution

This article talks about one solution - through the use of the MAILTO protocol.


As would be expected, when attempting to hyperlink to an HTTP (URL) address, ToolBook understands that the hyperlink request will need to be sent to a browser window - so ToolBook will open a Browser if needed, and the browser understands that you are attempting to communicate with a Web Page.


However there are other protocols you can specify to do other things. For example you can reference an FTP address to communicate with an FTP server.


For our purposes we want to take advantage of the MAILTO protocol, as it knows how to open an email window from within the users default mail client program.


For example, lets say you wanted a button in your ToolBook file for users to click on in order to send comments back to you. You would draw your button and then do the following:


  1. Open the Hyperlink Editor for the button
  2. In the URL field type: mailto:youraddress@yoursite.com
  3. Click OK


Now the button will hyperlink to a MAILTO address, which will cause a browser window to open (since the MAILTO feature is a browser functionality), and then the browser will open your default mail client window and show it already addressed to: youraddress@yoursite.com.

NOTE 1

It is not possible to open the Email window, fill it out and automatically send it using the MAILTO protocol. It is up to the end user to press the SEND button in their email client to send the mail.

NOTE 2

The fact that a browser window will have to open (if one is not already open), typically makes the use of this feature undesirable for Native ToolBook users. However if exported to DHTML and run in a Browser, a browser window is already open thus another one does not need to open.


SPECIFYING OTHER PARAMETERS

It is possible to specify the SUBJECT, CC, BCC and/or BODY parameters of a new mail message. Note that the support for these extra parameters depends on the email client the user has installed. Not all email client programs support the use of all of these parameters. Below are examples of the use of the various parameters.


  SUBJECT

  mailto:employee@company.com?subject=Hello World


  CC

  mailto:employee@company.com?cc=employee2@company.com


  BCC

  mailto:employee@company.com?bcc=employee3@company.com


  BODY

  mailto:employee@company.com?body=This is the body text


Combining more than one parameter

It is likely that you would want to combine more than one of these available parameters so that you specify their address and perhaps also the subject line and also some predesignated body text.


To do this you simply chain them together using an Ampersand character in any order you like. For example:


mailto:you@you.com?subject=General Comments&body=Type Here

mailto:you@you.com?subject=Misc&BCC=admin@you.com&body=Type Here



KEYWORDS: 21917 P2306




Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor