Microsoft KB Archive/251884

= PUB2000: How to Use JScript to Send Form Results as E-mail =

PSS ID Number: 251884

Article Last Modified on 12/9/2002

-

The information in this article applies to:


 * Microsoft Publisher 2000

-



This article was previously published under Q251884



SUMMARY
When you upload a Web page to an Internet service provider (ISP) that does not support FrontPage Server Extensions 3.0 or later on their Web host, you must rely on scripts provided by the ISP.

The following JScript code allows you to send Microsoft Publisher form results directly to your e-mail address.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

http://www.microsoft.com/partner/referral/

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

You can insert the following script sections into the Web page using the HTML Code Fragment tool.

NOTE: These scripts work differently with different combinations of Web browsers and e-mail client software.

Some combinations, such as Netscape Navigator and Netscape Mail place the form data into the actual e-mail message. Internet Explorer 5 and Outlook 2000 attach the form data to the e-mail message as a file attachment named Postdata.att. This attachment is a text file that you can open in any word processor or text editor.

For more information about using HTML Code Fragments, click Microsoft Publisher Help on the Help menu, type How do I use HTML Code Fragments in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

The following sample code pulls information from two single-line text boxes, one check box, and two option buttons. These form controls are used as outlined in the following table.


 * Used for a set of exclusive options.

Place this HTML code fragment at the top of the page. The size of the frame does not matter, nor does its horizontal placement as long as it is above the form controls. 

  This code fragment implements the Submit and Reset buttons, and it must be placed below the form controls on the Web page. Horizontal position does matter here, so you need to preview this page to center the two command buttons.

When you preview the Web page, you may receive the following message:

The form on Page (x) does not have a Submit button. You must add a Submit button for the form to work.

If you receive this message, click OK.

This HTML code terminates the dataForm section of the Web page and then creates a form to send data as a mailto: post. The data is encoded into a multipart format to allow the JScript code to work.

Finally, the onSubmit property calls the sendMail function and sends this function the newly created form.

The actual data is compiled into the formBody object, which is sent with the e-mail message.

Lastly, we declare the start of a new , to ensure that the default  tag that Publisher places at the end of the page has a corresponding start tag.     &#xa0;&#xa0;    NOTE: When you click the Submit button, a warning is displayed in your Web browser regarding the e-mail message you are attempting to send. Click Yes or OK to dismiss the warning.

This JScript section illustrates how to use the above coding concepts with the default Web forms. To properly use this code, it is paired with the code that implements the Submit and Reset buttons. The default form that is used is the General Response Form from the Design Gallery's Web Reply Forms collection.

To properly use this code, you must ungroup the General Response Form, and then delete the Submit and Reset buttons.

NOTE: Remember to place this code above the General Response Form. 

<div class="references_section">