Help building javascript to send email as an email not attachement

New Here ,
Jan 31, 2018

Copy link to clipboard

Copied

I have this code and not able to make it work   I have a PDF form that I would like to send an email to the email in the field ("Email").  However I do not want it as a PDF attachment, I would like to copy all the info in the PDF and paste into the email just like I see it on my screen.  Here is my code:

var subject1 = "SSC Triage Assistance Request: " + this.getField("CID").value,
var address1 = this.getField("Email").value,
var body1 = this.getField("CID").value,
+            this.getField("Order").value,
+           this.getField("Container").value,
  +          this.getField("Service").value,
   +         this.getField("Date").value,
    +        this.getField("Address").value,
     +       this.getField("Server").value,
      +      this.getField("Supervisor").value,
       +     this.getField("Error").value,
+
"Due to an Order Entry error we are requesting your assistance with completing a manual move as noted below"\n +

+           this.getField("Superuser").value,
  +          this.getField("Triage").value,
   +         this.getField("Name").value,
    +        this.getField("Phone").value,
     +       this.getField("Placement").value,
      +      this.getField("Facing").value,
       +     this.getField("Gated").value,
        +    this.getField("Code").value,
         +   this.getField("Cross1").value,
          +  this.getField("Cross2").value,
        +  this.getField("Special").value;

event.target.submitForm({CURL:"mailto:" +address1 + :?Subject=" + subject1 + "&body=" + body1 +"",cSubmitAS:"PDF",cCharset:"utf-8:});

Any help would be greatly appreciated. Thank you in advance for any suggestions. I am brand new to scripting so dumb down any answers!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Then it might not work... Try this, though, as the last line of the code, instead of the submitForm command:

app.launchURL("mailto:" + address1 + "?subject=" + subject1 + "&body=" + body1);

Of course, that will not send the email, just create a Draft that the user has to then manually send.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

714

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Help building javascript to send email as an email not attachement

New Here ,
Jan 31, 2018

Copy link to clipboard

Copied

I have this code and not able to make it work   I have a PDF form that I would like to send an email to the email in the field ("Email").  However I do not want it as a PDF attachment, I would like to copy all the info in the PDF and paste into the email just like I see it on my screen.  Here is my code:

var subject1 = "SSC Triage Assistance Request: " + this.getField("CID").value,
var address1 = this.getField("Email").value,
var body1 = this.getField("CID").value,
+            this.getField("Order").value,
+           this.getField("Container").value,
  +          this.getField("Service").value,
   +         this.getField("Date").value,
    +        this.getField("Address").value,
     +       this.getField("Server").value,
      +      this.getField("Supervisor").value,
       +     this.getField("Error").value,
+
"Due to an Order Entry error we are requesting your assistance with completing a manual move as noted below"\n +

+           this.getField("Superuser").value,
  +          this.getField("Triage").value,
   +         this.getField("Name").value,
    +        this.getField("Phone").value,
     +       this.getField("Placement").value,
      +      this.getField("Facing").value,
       +     this.getField("Gated").value,
        +    this.getField("Code").value,
         +   this.getField("Cross1").value,
          +  this.getField("Cross2").value,
        +  this.getField("Special").value;

event.target.submitForm({CURL:"mailto:" +address1 + :?Subject=" + subject1 + "&body=" + body1 +"",cSubmitAS:"PDF",cCharset:"utf-8:});

Any help would be greatly appreciated. Thank you in advance for any suggestions. I am brand new to scripting so dumb down any answers!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Then it might not work... Try this, though, as the last line of the code, instead of the submitForm command:

app.launchURL("mailto:" + address1 + "?subject=" + subject1 + "&body=" + body1);

Of course, that will not send the email, just create a Draft that the user has to then manually send.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

715

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 31, 2018 0
Most Valuable Participant ,
Jan 31, 2018

Copy link to clipboard

Copied

Is this file going to be used in Acrobat only, or also in the free Reader? If Acrobat only then you should use the mailMsg method of the app object. If in Reader then it's more complicated. Basically you can only do it using the launchURL method and a "mailto" command, but it has a length limit, so it might not work correctly.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
New Here ,
Jan 31, 2018

Copy link to clipboard

Copied

This PDF will be used on Adobe Acrobat Reader DC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Most Valuable Participant ,
Jan 31, 2018

Copy link to clipboard

Copied

Then it might not work... Try this, though, as the last line of the code, instead of the submitForm command:

app.launchURL("mailto:" + address1 + "?subject=" + subject1 + "&body=" + body1);

Of course, that will not send the email, just create a Draft that the user has to then manually send.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
New Here ,
Jan 31, 2018

Copy link to clipboard

Copied

I am getting an error here:

var body1 = this.getField("CID").value,

It says SyntaxError: missing variable name

2: at line 3

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Adobe Community Professional ,
Jan 31, 2018

Copy link to clipboard

Copied

You've got a three types of errors in the code. Mainly that commas are not line endings.

First, Replace the comma at the end of the statement  lines  with a ";"  This is one of your syntax errors

Next, remove all the commas at the end of the text lines that are used in the string concatenation.

Make sure you know what the end of statement line means as opposed to the end of a text line.

Next, on this line,

"Due to an Order Entry error we are requesting your assistance with completing a manual move as noted below"\n +

move the \n into the quotes.

And finally, the submitForm() function submits a form. This is what it does, so it will always produce an email with an attachment.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 1
New Here ,
Jan 31, 2018

Copy link to clipboard

Copied

OK, so I got all that info corrected however when I click on it, it doesnt do anything?  Any suggestions?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Adobe Community Professional ,
Jan 31, 2018

Copy link to clipboard

Copied

Run the script from the Acrobat Console Window so you can check on all the results as they happen.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
New Here ,
Jan 31, 2018

Copy link to clipboard

Copied

I am so lost with this!!!  Is there a way I can upload my form or send it somewhere for someone to check it out for me?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 31, 2018 0
Most Valuable Participant ,
Feb 01, 2018

Copy link to clipboard

Copied

You've already uploaded your script. Now you've corrected it, please upload it again. This process goes on and on, even for experienced programmers, so you've probably still got some errors.

First though RUN IT FROM THE JAVASCRIPT WINDOW. If you are having problems doing this, let us know. We would much rather help you problem solve than read your code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 01, 2018 1
Adobe Community Professional ,
Feb 01, 2018

Copy link to clipboard

Copied

You'll find a video tutorial here on using the JavaScript Console Window.

Free Video Content & Full Listing of Available Videos

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 01, 2018 1