PDF Editing Issues

Use Acrobat JavaScript to Email a PDF with a CC and Dynamic Subject

Adam DavisAdam Davis Nov 19, 2026 868 views

Question details

The user needs to email a completed PDF form to a fixed recipient, copy a required manager address, and include form values in the subject.

Use Acrobat JavaScript to Email a PDF with a CC and Dynamic Subject
Product
Adobe Acrobat PDF forms and JavaScript
Device & OS
not provided
Scenario
A PDF form button should prepare an email with the completed document attached, a manager copied, and a subject assembled from form fields.
Observed behavior
The desired email has a fixed recipient, a CC address read from the form, and a subject containing form values.
Before you start

Open the form in Acrobat and check the exact names of the manager email and subject fields under Prepare a form. Confirm that Acrobat JavaScript is enabled and that an email application is configured for sending the message.

Solution 1Recommended

Use mailDoc with a Form Field for CC and a Dynamic Subject

Add a button action that checks the manager field and uses its value as the CC address.

Acrobat's mailDoc method uses cCc for the CC address and cSubject for the subject. Pass field values and variables as expressions, without quotation marks around them.

1
Check the field names

In Acrobat, open Prepare a form and inspect the field properties. The example below uses persontobeccd for the manager email and employeeName for a subject value; replace these names with the exact names in your form.

2
Open the button action

In Prepare a form, double-click the email button, open the Actions tab, select Mouse Up as the trigger, and choose Run a JavaScript.

3
Add the email script

In the JavaScript editor, replace the sample recipient and field names as needed, then enter: var managerField = this.getField("persontobeccd"); var nameField = this.getField("employeeName"); if (!managerField || !nameField) { app.alert("Check the form field names in the email script."); } else { var managerEmail = managerField.valueAsString.replace(/^\s+|\s+$/g, ""); if (!managerEmail) { app.alert("Enter the manager's email address before sending."); } else { var subjectLine = "Completed form - " + nameField.valueAsString; this.mailDoc({ bUI: true, cTo: "recipient@example.com", cCc: managerEmail, cSubject: subjectLine, cMsg: "Please find the completed form attached." }); } }

4
Test the form button

Close the editor, save the PDF, fill in the fields, and click the email button. Check the recipient, CC, subject, and attachment in the email window before sending. Also test with an empty manager field.

Use mailDoc with a Form Field for CC and a Dynamic Subject
Check the parameter and variable names: Use cCc as the mailDoc parameter. A name such as cCcAddr can be your own variable, but it should not replace cCc in the mailDoc options. The script checks that the manager field is not blank; it does not verify that the address is valid.
Free Microsoft Office alternative

Work with PDF Forms and Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its compatibility with common Office formats makes it easier to bring existing files into your workflow. Acrobat-specific mailDoc JavaScript still needs to be configured and tested in Acrobat.

Open and work with PDF documents alongside other filesCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why is the CC address appearing as text instead of a field value?

In the button's Run a JavaScript action, use cCc: this.getField("persontobeccd").valueAsString or pass a variable containing that value. Do not put quotation marks around the entire field expression.

How do I include more than one form value in the subject?

Build the subjectLine variable by joining field values and text, for example: var subjectLine = this.getField("employeeName").valueAsString + " - " + this.getField("projectName").valueAsString. Use your form's exact field names, then pass cSubject: subjectLine to mailDoc.

How can I stop the email when the manager field is empty?

In the button's JavaScript, check the manager field value before calling mailDoc. If it is blank, use app.alert to ask for an address and call mailDoc only when a value is present.

Does the script send the email automatically?

With bUI: true, mailDoc opens the email interface so the user can review and send the message. The result depends on the Acrobat environment and the configured email application.