How to use the mailto: protocol in a <FORM> action

Article translations Article translations
Article ID: 279460 - View products that this article applies to.
This article was previously published under Q279460
Expand all | Collapse all

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 "References" section.

NOTE: Use of the approach outlined in the "More Information" section has several limitations, including:
  • The other tags could exceed the maximum URL limitation by themselves. For instance, if there are a number of "To:" and "CC" 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
<FORM Action="mailto:xyz?Subject=Test_Post" METHOD="POST">
	mailto: protocol test:
	<Br>Subject: 
	<INPUT name="Subject" value="Test Subject">
	<Br>Body:&#xa0;
	<TEXTAREA name="Body">
	kfdskfdksfkds
	</TEXTAREA>
	<BR>
	<INPUT type="submit" value="Submit"> 
</FORM>
				
while having the FORM ACTION illustrated here does not:
<FORM Action="mailto:xyz" METHOD="POST">
	mailto: protocol test:
	<Br>Subject: 
	<INPUT name="Subject" value="Test Subject">
	<Br>Body:&#xa0;
	<TEXTAREA name="Body">
	kfdskfdksfkds
	</TEXTAREA>
	<BR>
	<INPUT type="submit" value="Submit"> 
</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:
Subject=Test+Subject&Body=%09kfdskfdksfkds%0D%0A%09
				
This is because the default ENCTYPE attribute for the FORM element is "application/x-www-form-urlencoded". To e-mail data in plain-text format instead, explicitly specify an ENCTYPE attribute of "text/plain". For instance:
<FORM Action="mailto:xyz" METHOD="POST" ENCTYPE="text/plain">
	mailto: protocol test:
	<Br>Subject: 
	<INPUT name="Subject" value="Test Subject">
	<Br>Body:&#xa0;
	<TEXTAREA name="Body">
	kfdskfdksfkds
	</TEXTAREA>
	<BR>
	<INPUT type="submit" value="Submit"> 
</FORM>
				
produces the following Body:
Subject=Test Subject
Body=	kfdskfdksfkds
				

REFERENCES

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
196461
196461 How to set up a form to post results by e-mail in FrontPage 2000
194088 How to set up a form to post results by e-mail in FrontPage 98
For more information about character limitations, click the following article numbers to view the articles in the Microsoft Knowledge Base:
208427 Maximum URL length is 2,083 characters in Internet Explorer
263909 ShellExecuteEx limits URL to MAX_PATH
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
http://msdn.microsoft.com/ie/

http://support.microsoft.com/iep

Properties

Article ID: 279460 - Last Review: April 28, 2012 - Revision: 5.0
APPLIES TO
  • Microsoft Internet Explorer 4.01 Service Pack 1
Keywords: 
kbhowto KB279460
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com