How to Send PDF Form Data in an Email Body Using JavaScript
Question details
The user wants to extract field values from a fillable PDF form and insert them directly into the body of an email message, rather than sending the form as an FDF or XFDF attachment.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Setting up a custom submit action on a fillable PDF form to email the entered data as plain text.
- Observed behavior
- By default, submitting the form attaches an FDF or XFDF data file to the email, which does not write the field values as text in the email body.
Verify that your PDF editing software supports JavaScript execution, and make a note of the exact field names (e.g., 'FirstName', 'LastName') used in your fillable form.
Use Acrobat JavaScript to Build and Send the Email Message
Use the Acrobat JavaScript API to retrieve the value of each form field, assemble a custom text string, and pass it to the app.mailMsg method to populate the email body.
While standard PDF form actions default to attaching data files, you can override this behavior by constructing the email message manually. By using JavaScript, you extract individual text strings and concatenate them into a single block of text.
Open your PDF form in your PDF editing software and enter the form editing or prepare form mode.
Double-click your text fields to open their properties and note down their exact names (for example, 'Prenom', 'Nom', 'Org').
Add a new Button element to your form, open its Properties, go to the Actions tab, select 'Run a JavaScript', and click Add.
In the JavaScript editor, enter your code using the app.mailMsg method. Example: app.mailMsg({bUI: false, cTo: "recipient@example.com", cSubject: "Form Submission", cMsg: "First name: " + this.getField("Prenom").value + "\nLast name: " + this.getField("Nom").value});
Save the PDF, exit form editing mode, fill in some test data, and click your new button. Your default email client should open with the form data neatly formatted in the message body.

Manage Fillable PDF Forms Easily with WPS Office
WPS PDF provides highly compatible tools for viewing, filling, and managing interactive PDF forms. Whether you are extracting form data or sharing documents, WPS Office offers a streamlined, user-friendly experience.
- 1. Download and install: Download WPS Office from the official website and install it on your computer.
- 2. Open the PDF form: Launch WPS PDF and open your interactive fillable PDF form.
- 3. Fill in the details: Click directly on the text fields, checkboxes, and drop-downs to input your information.
- 4. Share via email: Click the 'Share' or 'Email' icon on the top toolbar to quickly attach the completed PDF to a new email message.

Frequently Asked Questions
Why does my PDF form submit as an FDF attachment instead of plain text?
Standard PDF form submission features are designed to send data as structured files (FDF, XFDF, or XML) so it can be automatically parsed by a server or database. Sending it as plain text requires custom JavaScript.
Do I need programming experience to use app.mailMsg?
Basic understanding of JavaScript is sufficient. You primarily need to know how to retrieve field values using the this.getField("FieldName").value method and how to concatenate text strings.
Will this JavaScript email action work on mobile PDF viewers?
Most mobile PDF viewer apps and built-in web browser plugins do not support advanced JavaScript methods like app.mailMsg. For best results, the form should be completed using a dedicated desktop PDF application.
What is the difference between doc.mailDoc() and app.mailMsg()?
The doc.mailDoc() method is primarily used to attach the entire PDF document to an email, while app.mailMsg() allows you to silently draft an email message with custom text in the body, without necessarily attaching the document.




