Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adding variable Value into Email Submit Button

Not applicable

is it possible to dynamic add an variable Field Value, (text field value from the form) into the Email Subject Field of the Email Submit Button?

Another question is if it is possible to add the Email address?


Johannes Lehninger
8 Replies
Level 10
Level 10
Are you emailing from the form or from a process step in a workflow process?
Not applicable
Hi Paul,

I want to email from the form.
Level 10
Level 10
Ok there are a couple of ways to accomplish this. If you are using a MAPI client for email you can use an Acrobat/Reader api that interacts with the Mapi interface. To get access to it you can use this javascript code:

var oDoc =; //This will return a doc object in Acrobat

oDoc.mailDoc(UI, To address, CC Address, BCC address, Subject, Message);

where UI is a boolean indicating whether to disply a UI or not (this is always true with newer versions of Reader/Acrobat - for security reasons), To Address is the address as a string of the recipient, CC address is the email address of the CC recipient, BCC address is the address of the blind CC recipient, Subject is a string representing the subject of the email, and message is a string representing the message body of the email. In all cases a field's value can be used as the string or in concatenation with other text in the string.

The other way to do this is by using the mailto protocol with a submit button. Put a button on your form and make it a submit button. In the submit URL you can use the mailto protocol to submit to. Put a bogus entry in so that the right structure is set up in the XFA template. Now when you have the info on the form you can access the submit URL programmatically by using this command:

xfa.resolveNode("emailButtonName.#event") = "mailto:emailaddress?subject=This is my subject?body=This is the body of the message";

Any parts of the mailto can be substituted with values from your fields (as we did above).

I have also included a reference to the mailto syntax:

Hope that helps
Not applicable

it works with the first solution but,

what is the correct syntax for the substitution when I want to use the subject from the form field?

xfa.resolveNode("send.#event") = "";
Level 10
Level 10
Assuming you are programming in JavaScript you would use:

xfa.resolveNode("send.#event") = " is the subject with some data from a field ..." + fieldname.rawValue + "&body=test";
Not applicable
thx, everything worked fine

one final question on this topic: is it possible to give the attachment a defined name (test.pdf) ? or is it only possible to name it with a random value (_17s162en1e55f2h2m.pdf) ?
Level 10
Level 10
The random value is the temp file that is created when you are running in preview mode. I do not think you will see that when you save the file as a PDF and run it like that. Bottom line is no you cannot adjust the file is the name of the PDF that is being viewed.
Level 1
Level 1

Thank you so much for posting this. I modified the code for my purposes. Someone may find this helpful:

//Grab the email from the dropdown or textfield or whatever field

var cToAddr = this.getField("SelectEmailDropDownMenuName").value;

// Second, if needed add the client CC email addresses

var cCCAddr = ";";

// or grab cc dynamically bu uncommenting this line

//var cCCAddr = this.getField("SelectEmailAdressName").value;

// Now get the beneficiary email only if it is filled out

var cBenAddr = this.getField("AnotherEmailField").value;

if(cBenAddr != "")

cCCAddr += ";" + cBenAddr;

// Set the subject and body text for the email message

var cSubLine = "My Subject Line Form"

var cBody = "Thank you for submitting your form.\n" + "Save the filled form attachment for your own records. "

// Send the entire PDF as a file attachment on an email

this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});