Other PDF Issues

How to Send a PDF by Email Using Acrobat mailDoc() JavaScript

Adam DavisAdam Davis Oct 28, 2026 869 views

Question details

The user needs to send a PDF document via email using the mailDoc() JavaScript function in Adobe Acrobat, but the script is failing to execute.

How to Send a PDF by Email Using Acrobat mailDoc()
Product
Adobe Acrobat Pro DC
Device & OS
Windows 10
Scenario
Setting up a button with a JavaScript action to automatically attach the current PDF to an email.
Observed behavior
The action does not run due to a syntax error in the string assignment, preventing the email client from launching.
Before you start

Ensure your default email client (such as Outlook or Windows Mail) is properly configured on your Windows 10 device, and verify that Adobe Acrobat's security settings permit JavaScript execution.

Solution 1Recommended

Fix the Syntax Error and Trigger mailDoc() via User Action

Correct the JavaScript string syntax in your variable assignment and ensure the script is executed via a permitted user action like a Mouse Up event.

Adobe Acrobat requires specific formatting for JavaScript execution. A common mistake is terminating a string concatenation with a period instead of a semicolon. Additionally, for security reasons, functions like mailDoc() must be triggered by an explicit user action rather than running automatically.

1
Access Button Properties

In Adobe Acrobat Pro DC, enter 'Prepare Form' mode. Right-click the button intended to trigger the email and select 'Properties'.

2
Set the Trigger Action

Navigate to the 'Actions' tab. Select 'Mouse Up' as the trigger event, choose 'Run a JavaScript' from the 'Select Action' dropdown, and click 'Add'.

3
Correct the Script Syntax

Fix the syntax error in your variable assignment by replacing the trailing period with a semicolon. For example: var cBody = 'Please find the attached document for ' + this.getField('NAME').value;

4
Call the mailDoc() Method

On the next line, execute the method by adding: this.mailDoc({bUI: true, cTo: 'example@email.com', cMsg: cBody}); Click 'OK' to save the script.

5
Test the Email Button

Exit form editing mode and click your button. Your default email client will open with the PDF attached and the message body pre-filled.

Fix the Syntax Error and Trigger mailDoc() via User Action
Security Prompt Warning: Acrobat may prompt you with a security warning the first time you run this script. You must grant permission for the application to communicate with your email client.

Send PDFs by Email Instantly with WPS Office

If configuring JavaScript and debugging code in Adobe Acrobat is too complex, WPS Office provides a built-in, one-click solution to send any PDF document as an email attachment without writing a single line of code.

  1. 1. Open your PDF in WPS: Launch WPS Office and open the PDF document you wish to share via email.
  2. 2. Locate the Share Function: Navigate to the top toolbar of the WPS PDF interface and click on the 'Share' or 'Email' icon.
  3. 3. Launch Email Client: Select 'Email'. WPS Office will automatically launch your default desktop email client with the PDF document already attached.
  4. 4. Send the Document: Fill in the recipient's email address, add your desired subject line, and hit send.
One-click email sharing directly from the PDF viewer interface.No JavaScript coding or complex trigger configuration required.Highly compatible with standard Adobe PDF formats and default email clients.Lightweight, fast, and user-friendly PDF editing.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't the mailDoc() function opening my email client?

This usually occurs if there is a syntax error in your JavaScript code, if Acrobat's security settings are blocking the action, or if your default email application is not correctly designated in your Windows 10 OS settings.

Can I automatically send the PDF without user interaction using mailDoc?

No, Adobe Acrobat's security model dictates that the mailDoc() method must be triggered by a direct, permitted user action, such as a 'Mouse Up' event on a form button.

How do I dynamically attach form field data into the email body?

You can retrieve form data using this.getField('FieldName').value and concatenate it into your message string before passing that string to the cMsg parameter of the mailDoc() function.