How to Add PDF Form Fields to an Email Subject and Message
Question details
The user wants to configure a PDF form to dynamically extract filled data (such as names, dates, and companies) and automatically insert these values into the subject line and message body of a submission email.

- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form for data collection that needs to be submitted via email with a dynamically generated subject line based on user input.
- Observed behavior
- Needs the correct scripting method to read specific PDF form field values and concatenate them into an email trigger action without errors.
Ensure you have noted the exact, case-sensitive names of your PDF form fields, as JavaScript requires precise matching to successfully pull the filled data.
Use JavaScript to Configure a Custom Email Submit Button
Using built-in PDF JavaScript allows you to extract field values as strings and pass them into the email client's automated message.
To achieve a dynamic email submission, you cannot use the standard 'Submit a form' action. Instead, you must use a 'Run a JavaScript' action attached to your submit button. This script reads the values from your form, concatenates them into strings for the subject and body, and triggers the email client.
Open your PDF form in edit mode. Right-click the 'Submit' button you want to configure, select 'Properties', and navigate to the 'Actions' tab.
Under 'Select Action', choose 'Run a JavaScript' from the drop-down menu and click the 'Add' button to open the JavaScript Editor.
Define variables to read your form fields using the getField method. For example: var officerName = this.getField("Officer name").valueAsString; var company = this.getField("Company").valueAsString;
Combine the extracted values with your static text using the + operator. Example: var mailSubject = company + " - Submission from " + officerName; var mailBody = "Dear " + officerName + ",\n\nPlease find the attached form.";
Add the command to launch the email with the constructed subject and body variables: app.mailMsg({bUI: true, cTo: "central@example.com", cSubject: mailSubject, cMsg: mailBody}); Click 'OK' to save the script.

Create and Manage PDF Forms Effortlessly with WPS Office
WPS Office provides a comprehensive suite of PDF editing tools that allow you to quickly design interactive forms, insert text fields, and share your collected data seamlessly.
- 1. Open WPS PDF Editor: Launch WPS Office, open your PDF document, and navigate to the 'Form' tab on the top ribbon.
- 2. Insert Interactive Fields: Click on 'Text Field', 'Check Box', or 'Push Button' to draw interactive elements directly onto your document.
- 3. Customize Field Properties: Right-click any newly created field, select 'Properties', and assign specific names or formatting rules to ensure organized data collection.
- 4. Share via Email: Once your form is designed and filled, use the 'Share' or 'Email' button in the top right corner to send the document instantly.

Frequently Asked Questions
Why is my PDF form JavaScript not opening the email client?
This usually happens because JavaScript execution is disabled in your PDF reader's security preferences, or the default email client is not configured correctly on your operating system. Check the application preferences to ensure JavaScript is allowed.
Can I format the automated email body using HTML?
No, the standard app.mailMsg JavaScript function for PDF forms only supports plain text. If you include HTML tags, they will be displayed as raw text in the resulting email message.
How do I format date fields properly before adding them to the email subject?
You can format dates using the util.printd method in your JavaScript code. Extract the date object first, then format it (e.g., util.printd("mm/dd/yyyy", dateVar)) before appending it to your subject string.
Will this automatic email feature work if users fill the form in a web browser?
Generally, no. Most web browsers' built-in PDF viewers do not support advanced Acrobat JavaScript or the app.mailMsg function. Users should be advised to download the PDF and open it in a dedicated desktop application like WPS PDF or Adobe Acrobat.




