Copy link to clipboard
Copied
I have submit button on a form that when clicked it sends a PDF attachement to a static mailto, with the cc, subject line, and body all based on a field entry.
I based my code on this link:
https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address/
As a result this is my code.
var cToAddr = "application@email.com";
var cCCAddr = this.getField("Employee_Email").value;
var cSubLine = "Application for" + this.getField("Employee_Name").value;
var cBody = this.getField("Employee_Name").value + "has submitted an Application for review.";
event.target.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});
It appears my code is just wrong. I've tried alternate variations but this seems to be the closest. The Javascript Debugger says:
Acrobat EScript Built-in Functions Version 10.0
Acrobat SOAP 10.0
SyntaxError: missing } after property list
4:
SyntaxError: missing } after property list
4:
SyntaxError: unterminated string literal
7:
SyntaxError: unterminated string literal
7:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
SyntaxError: unterminated string literal
3:
TypeError: event.target.mailDoc is not a function
5:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
5:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
5:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
1:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
1:Field:Mouse Up
TypeError: event.target.mailDoc is not a function
1:Field:Mouse Up
Clearly the MouseUp function doesn't like the code, though it's what I want to happen. Click on the button and it submits like this would:
this.submitForm({cURL: "mailto:application@email.com", cSubmitAs: "PDF"});
At this point, I'm at a loss of how to make this function properly.
1 Correct answer
That article includes code for both LiveCycle and regular AcroForms. You've copied the LiveCycle (XFA) code.
So first, change
event.target.mailDoc
to
this.mailDoc
because "mailDoc" is a document function.
However, you have a lot of other reported errors that do not match the script you've posted. I suspect they are for other scripts on your form. When you are setting up a form it is a really good idea to do one thing at a time, and test it, so you don't have a whole bunch of erro
...Copy link to clipboard
Copied
Use
this.mailDoc
Copy link to clipboard
Copied
That article includes code for both LiveCycle and regular AcroForms. You've copied the LiveCycle (XFA) code.
So first, change
event.target.mailDoc
to
this.mailDoc
because "mailDoc" is a document function.
However, you have a lot of other reported errors that do not match the script you've posted. I suspect they are for other scripts on your form. When you are setting up a form it is a really good idea to do one thing at a time, and test it, so you don't have a whole bunch of errors walking on top of one another. I would strongly suggest deleting all scripts from the document and rebuilding the form one script at a time.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thank you so much. It works now. I will look at those other scripts.

