0

I have a PDF form, it's very basic, only 4 fields. I need to add a button and have it send an email out based on data entered into the form.

Currently I have the following.

var's for the four fields.

var cName = this.getField("Name").value; 
var cNumber = this.getField("Phone").value; 
var cEMail = this.getField("Email").value; 
var erAgent = this.getField("Agent").value;

Email structure.

var erBody = cName + "has entered their details and with to be contacted on " +  cNumber + " for phone or can be EMailed at " + cEMail;
var erSub = cName + " details";
var erEmailURL = "mailto:" + erAgent + "&subject=" + erSub + "&body=" + erBody;

When I add a submit function, i can't get any of them to work. I have added a few below.

app.mailMsg({cURL: encodeURI(erEmailURL)});

app.mailMsg({cURL:"mailto:" + erAgent + "&subject=" + erSub + "&body=" + erBody});

Neither of these seem to work. I have also tried.

this.submitForm({cURL: encodeURI(erEmailURL), cSubmitAs:"XML", cCharSet:"utf-8"});
this.submitForm({cURL:"mailto:" + erAgent + "&subject=" + erSub + "&body=" + erBody, cSubmitAs:"XML", cCharset:"utf-8"});

Again, seemingly not working.

Can anyone point out my mistake? or point me in the right direction.

Thanks for reading. :)

Bob007
  • 109
  • 1
  • 7
  • Are there any error messages that appear? –  Jan 25 '16 at 20:18
  • Sadly no. I hit the button and nothing. . I have used the standard submit function and I am able to email that way. But when I try it with my script it does nowt. – Bob007 Jan 25 '16 at 20:36

1 Answers1

1

There is a mischmasch of Acrobat JavaScript and web browser JavaScript/URI assembly.

Have a closer look at the mailForm() and related methods in the Acrobat JavaScript documentation (which is part of the Acrobat SDK documentation, downloadable from the Adobe website).

In short, the correct syntax for mailForm() in your context is in this line:

this.mailForm({
cTo: erAgent,
cSubject: erSub,
cMsg: erBody
})

You'd have to adjust accordingly.

If for whatever reason you insist on following an URL-coded path, you would use the getURL() method.

Max Wyss
  • 3,549
  • 2
  • 20
  • 26
  • Thanks Max. I grabbed the SDK and took a look, building the PDF in foxit, but the issue was with a field I have given an incorrect case setting, stopped the whole script working. – Bob007 Jan 26 '16 at 20:25