How to Automatically Create an Email Subject from PDF Form Data
Question details
The user wants to dynamically generate an email subject line using specific data inputted into PDF form fields when the form is submitted via email.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where clicking the submit button automatically emails the document with a personalized subject line based on the user's entries.
- Observed behavior
- A standard static email link (mailto) cannot dynamically read form fields; achieving this requires a JavaScript-based submit action.
Ensure you have access to a professional PDF editor that supports form field creation and JavaScript execution, such as Adobe Acrobat Pro.
Use Acrobat JavaScript to Build Dynamic Email Subjects
Create a custom submit button with an embedded JavaScript action to read the required form fields and concatenate them into the email subject line.
A standard 'mailto:' link inside a PDF is strictly static and cannot interpret the data a user has entered into the form. To achieve dynamic behavior, you must leverage Adobe Acrobat's JavaScript capabilities.
By writing a simple script attached to a button, the PDF can retrieve the value of any named text field (such as a client name or ID number) and build a dynamic email action that works seamlessly with common desktop email clients.
Open your interactive PDF in Adobe Acrobat Pro and select 'Prepare Form' from the tools menu to access the form editing tools.
Click the 'Add a Button' icon in the toolbar and place it on your document. Give the button an appropriate name, such as 'SubmitForm'.
Right-click the newly created button and select 'Properties'. Navigate to the 'Actions' tab at the top of the Properties dialog box.
Under the 'Select Action' dropdown menu, choose 'Run a JavaScript', then click the 'Add' button to open the JavaScript Editor.
Write your custom script to fetch the field data and construct the email. For example: var mailSubject = this.getField('ClientName').valueAsString; app.mailMsg(true, 'recipient@example.com', '', '', mailSubject, 'Please find the attached form.');
Click 'OK' to close the editor and properties window. Save your PDF document, exit the form editing mode, and test the button by filling out the field and clicking submit.

Edit, Fill, and Share PDF Forms with WPS Office
WPS Office offers a comprehensive suite of PDF tools that make it easy to view, interact with, fill out, and reliably share PDF forms across all your devices.
- 1. Install WPS Office: Download and install the free version of WPS Office from the official website.
- 2. Open Your PDF Form: Launch WPS PDF and open the interactive PDF document you need to fill out or manage.
- 3. Fill the Form Fields: Navigate to the form fields within the document; WPS PDF will automatically recognize them, allowing you to easily type in your data.
- 4. Share via Email: Once completed, use the integrated 'Share' or 'Email' function located in the top menu to attach your filled PDF to a new message in your default email client.

Frequently Asked Questions
Can I include data from multiple different form fields in the same email subject line?
Yes. Within your JavaScript code, you can use the 'this.getField()' method multiple times to retrieve variables from different fields, and then combine them using standard JavaScript string concatenation (e.g., field1 + ' - ' + field2) before setting it as the subject line.
Why isn't my JavaScript submit button opening the email client?
This usually happens for one of two reasons: either the PDF viewer being used does not support JavaScript (common with built-in web browser viewers), or the operating system does not have a default desktop email client configured to handle standard mail actions.
Does this dynamic email feature work with web-based email services like Gmail?
It depends on the user's local operating system settings. If the user has configured their OS to use a web browser and Gmail as their default mail handler for 'mailto' links, the JavaScript action will successfully open a new Gmail draft with the dynamically generated subject.




