Use Acrobat JavaScript to Email a PDF with a CC and Dynamic Subject
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.

- 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.
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.
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.
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.
In Prepare a form, double-click the email button, open the Actions tab, select Mouse Up as the trigger, and choose Run a JavaScript.
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." }); } }
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.

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.

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.




