How to Create PDF Buttons That Submit Forms by Email
Question details
The user wants to create a PDF form with a button that submits data via email, sets recipient addresses dynamically, and automatically handles file attachments.

- Product
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form for automated email submission with dynamic recipients and file attachments.
- Observed behavior
- PDF buttons can successfully use JavaScript to submit forms and set email addresses dynamically, but automatically attaching external files to the outgoing email is heavily restricted by the PDF reader and email client environments.
Ensure you are using a comprehensive PDF editor that supports form creation and document-level JavaScript execution. Both the sender and the recipient must have a properly configured default email client for the submission action to work.
Create an Email Submit Button Using JavaScript
Use button-level JavaScript to dynamically extract an email address from a form field and trigger an email submission.
Using JavaScript within a PDF form allows you to automate workflows, such as dynamically pulling an email address from a user's input field and opening a pre-addressed email draft.
However, due to security constraints enforced by modern PDF readers, you cannot use these scripts to automatically extract external files from a user's computer and attach them to the email.
Open your PDF form in a capable PDF editor such as Acrobat or WPS Office.
Navigate to the Form editing tools and insert a 'Push Button' onto your document page.
Double-click the newly added button to open its Properties. Go to the 'Actions' tab, select 'Mouse Up' as the trigger, and choose 'Run a JavaScript' as the action.
Enter the JavaScript code to define the email recipient based on a form field. For example: var email = this.getField('EmailField').value; app.mailMsg({bUI: true, cTo: email, cSubject: 'Form Submission'});
Save the PDF file, switch to the Hand or Selection tool, and click the button to verify it launches your default email client with the correct recipient address.

Manage Embedded File Attachments Before Submission
Since external files cannot be dynamically attached during the email submission process, users must embed necessary files into the PDF itself prior to clicking submit.
Build Interactive PDF Forms Using WPS Office
WPS Office provides comprehensive PDF editing tools, allowing you to easily insert text fields, checkboxes, and interactive buttons for form submissions without needing complex coding skills.
- 1. Open Your PDF Document: Launch WPS Office, go to the 'PDF' tab, and open the document you wish to turn into an interactive form.
- 2. Access Form Tools: Navigate to the 'Form' menu on the top ribbon to access the interactive form controls.
- 3. Insert a Push Button: Select the 'Push Button' tool and click on the page to draw the button at your desired location.
- 4. Configure the Submit Action: Double-click the button to open its properties, go to the actions tab, and set it to submit the form data or run a custom script.
- 5. Save and Distribute: Save your document as a standard PDF. It is now ready to be distributed to users for filling and submission.

Frequently Asked Questions
Why doesn't my PDF submit button attach external files automatically?
For security reasons, PDF readers restrict JavaScript from accessing a user's local file system. This prevents malicious scripts from automatically grabbing and emailing private files without the user's explicit consent.
Can I use different buttons for 'Yes' and 'No' responses in my PDF form?
Yes, you can create separate buttons and assign distinct JavaScript actions or form values to each. This allows your form logic to process different responses dynamically before sending the submission.
What happens if the user filling the form doesn't have a default email client set up?
If there is no default desktop email client configured on the user's device, the PDF submit button will fail to generate an outgoing email draft. In such cases, the user must save the filled PDF manually and attach it to an email via their webmail service.




