How to Submit a PDF Form by Email with a Dynamic Subject Line
Question details
The user wants to configure an interactive PDF form so that when the submit button is clicked, it emails the completed PDF as an attachment and automatically populates the email subject line using the value entered in a specific form field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form with an automated email submission button.
- Observed behavior
- The default 'Submit a Form' action does not natively support pulling dynamic values from form fields for the email subject line, requiring a script-based workaround.
Ensure your PDF editor supports JavaScript actions for form fields. You will also need the exact internal name of the text field that contains the data you want to use for the subject line.
Use a Run a JavaScript Action for the Submit Button
Replace the default form submission action with a custom JavaScript code that fetches the target field's value and generates an email with it as the subject.
To achieve a dynamic subject line, you must bypass the standard 'Submit a Form' trigger. Using the 'Run a JavaScript' action gives you full control over the email generation process, allowing you to extract user inputs and format the email properties before sending.
Right-click your submit button, select Properties, and navigate to the Actions tab. Select the existing 'Submit a Form' action in the list and delete it.
In the same Actions tab, change the 'Select Action' dropdown to 'Run a JavaScript' and click the 'Add' button.
In the JavaScript Editor window that opens, input your code. For example: var subj = this.getField('YourFieldName').value; this.mailDoc({cTo: 'receiver@example.com', cSubject: subj});
Save and click the button to test. If nothing happens, press Ctrl+J to open the JavaScript console and check for any syntax errors or missing field references.
Manage and Edit PDF Forms Easily with WPS Office
WPS Office offers a comprehensive PDF editor that allows you to easily view, fill out, edit, and share interactive PDF forms without needing complex or expensive software.
- 1. Open PDF in WPS Office: Launch WPS Office on your computer and open your interactive PDF form document.
- 2. Fill the Form: Click on the highlighted interactive fields to input your data, or use the 'Fill & Sign' tools in the toolbar.
- 3. Share via Email: Once completed, click the 'Menu' button, go to 'Share', and select 'Email' to quickly send your filled form as an attachment.

Frequently Asked Questions
Why isn't my PDF submit button opening my email client?
This usually happens due to a syntax error in your JavaScript or if your default email client is not configured correctly on your operating system. Press Ctrl+J in your PDF editor to open the JavaScript console and check for error messages.
Do dynamic subject lines work in all PDF readers?
No. Many third-party PDF viewers, mobile apps, and built-in web browser PDF readers restrict or do not support JavaScript actions for security reasons. Users should open the form in a dedicated PDF application.
Can I combine multiple fields into the email subject line?
Yes. In your JavaScript code, you can concatenate multiple field values. For example: var subj = this.getField('FirstName').value + ' - ' + this.getField('ProjectName').value;.




