Microsoft KB Archive/279460

= How to use the mailto: protocol in a  action =

Article ID: 279460

Article Last Modified on 5/11/2006

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q279460



SUMMARY
The sample code provided in this article applies to developers that want to submit the contents of an HTML form directly to an e-mail address. The code also applies to developers who run into the length limitations documented later in this article when using the mailto: protocol in other situations. For the latter case, the body text is often the limiting factor.

For more information about length limitations, see the articles listed in the &quot;References&quot; section.

NOTE: Use of the approach outlined in the &quot;More Information&quot; section has several limitations, including:  The other tags could exceed the maximum URL limitation by themselves. For instance, if there are a number of &quot;To:&quot; and &quot;CC&quot; recipients. A security popup when the user submits the FORM, as documented in the mailto protocol RFC, RFC2368. Internet Explorer uses MAPI to communicate with the default mail application. The e-mail client installed on the client computer must be MAPI-compliant. Microsoft Outlook and Outlook Express behave as described within. The e-mail client must have made the appropriate registry entries for this to work. For more information about the registry entries, click the following article number to view the article in the Microsoft Knowledge Base:

154359 How to change the default mail client for Internet Explorer



The more robust approach, which does not have the mailto: protocol limitations, is to submit the FORM to an ASP/CGI script on a Web server. The script packages the data into an e-mail message. For an example about how to do this by using ASP and Collaboration Data Objects (CDO), refer to following Microsoft Knowledge Base article:

186204 How to use CDONTS to collect and mail information from a user



MORE INFORMATION
One solution is using a FORM with an ACTION of POST instead. The caveat is that FORM elements cannot be used to fill in the various fields like Subject, Body, and and so forth because the mailto: protocol handler does not examine these fields. All the FORM data is packaged and e-mailed away.

So, having the FORM ACTION fills in the Subject field as follows  mailto: protocol test: Subject: <INPUT name=&quot;Subject&quot; value=&quot;Test Subject&quot;> <Br>Body:&#xa0; <TEXTAREA name=&quot;Body&quot;> kfdskfdksfkds </TEXTAREA> <BR> <INPUT type=&quot;submit&quot; value=&quot;Submit&quot;> </FORM> while having the FORM ACTION illustrated here does not:

<FORM Action=&quot;mailto:xyz&quot; METHOD=&quot;POST&quot;> mailto: protocol test: <Br>Subject: <INPUT name=&quot;Subject&quot; value=&quot;Test Subject&quot;> <Br>Body:&#xa0; <TEXTAREA name=&quot;Body&quot;> kfdskfdksfkds </TEXTAREA> <BR> <INPUT type=&quot;submit&quot; value=&quot;Submit&quot;> </FORM> In both cases, the FORM data is e-mailed in as an Attachment, in an encoded format. For instance, in the preceding case, this is how the data looks: <pre class="fixed_text">Subject=Test+Subject&Body=%09kfdskfdksfkds%0D%0A%09 This is because the default ENCTYPE attribute for the FORM element is &quot;application/x-www-form-urlencoded&quot;. To e-mail data in plain-text format instead, explicitly specify an ENCTYPE attribute of &quot;text/plain&quot;. For instance: <FORM Action=&quot;mailto:xyz&quot; METHOD=&quot;POST&quot; ENCTYPE=&quot;text/plain&quot;> mailto: protocol test: <Br>Subject: <INPUT name=&quot;Subject&quot; value=&quot;Test Subject&quot;> <Br>Body:&#xa0; <TEXTAREA name=&quot;Body&quot;> kfdskfdksfkds </TEXTAREA> <BR> <INPUT type=&quot;submit&quot; value=&quot;Submit&quot;> </FORM> produces the following Body: <pre class="fixed_text">Subject=Test Subject Body=  kfdskfdksfkds

<div class="references_section">