Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding multiple email addresses to javascript for a Submit button on a .pdf form

New Here ,
Mar 23, 2020 Mar 23, 2020

I have a javascript that works with a cTo and a cCc. however, I want to add a second address to the cCc line. When I do it only sends to the second address listed and not the first. How do I get it to send to all three addresses? 

 

TOPICS
PDF forms
5.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 24, 2020 Mar 24, 2020

Well, there is a problem with the code, but it's not the cc. The comma is missing from the end of "bUI" parameter.  This would have been the issue first to be reported in the console window. 

I tested this code (fixed the comma) and it works just fine. There is no problem with the cc line.

 

To verify this, change the bUI parameter to true, so you see the result in the email dialog. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 23, 2020 Mar 23, 2020

You can add multiple email addresses, if you separate them using a semi-colon.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2020 Mar 23, 2020

doesn't work, the Acrobat won't accept the javascript with a semicolon, have to use a comma. Still only gives me the second email listed. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 23, 2020 Mar 23, 2020

Please post your code, I think you are missing something basic.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2020 Mar 23, 2020

var emailSubject = "New Commercial Card Request Form submitted for " + this.getField("COMPANYNAME ").valueAsString + " " + this.getField("DATE").valueAsString;
var emailMsg = "New Commercial Card Request Form submitted for " + this.getField("COMPANYNAME").valueAsString ;

this.mailDoc({
cTo: ("CashManagementProducts@XYC.com"),
cCc: ("dsanders@XYC.com"),
cSubject: (emailSubject),
cMsg: (emailMsg)
})

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2020 Mar 23, 2020

that code is obviously with only one email in the To and the CC lines. Can't add a second one to either and have it work right. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2020 Mar 24, 2020

In order for us to do debug, you have to post the code that doesn't work 😉  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2020 Mar 23, 2020

Hi,

 

Please refer to page 287 of the JavaScript for Acrobat API Reference:

 https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf

 

Like Thom and Try67 have suggested some basic things were skipped. You need to remove the parenthesis when using the parameters cTo   and cCc , you alse need to input all emails within the quotes separated by semicolon.

 

The this.mailDoc  part should look like this:

 

 

this.mailDoc({
bUI: false,
cTo: "CashManagementProducts@XYC.com; anotherCCcontact_1@XYC.com",
cCC: "dsanders@XYC.com; anotherCCcontact_2@XYC.com; anotherCCcontact_3@XYC.com",
cSubject: "your subject here",
cMsg: "your message, yari, yara, blassi, blassi, etc."
});

 

 

Also NOTE:  that bUI  part needs to be set. Using the JavaScript for Acrobat API Reference on page 288  see quote

" If false, the cTo parameter is required and all others are optional. "

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2020 Mar 24, 2020

Ok, so I tried (kinda) what you instructed though your suggestion did not include the variable email subject and message. This is the code I entered. When I try to close the javascript box in Acrobat, it highlights the lines with the two email addresses. What am I doing wrong? 

 

this.mailDoc({

bUI: false

           cTo:       "CashManagementProducts@ABC.com",

           cCc:       "email1@ABC.com";"email2@ABC.com",

           cSubject:  var emailSubject = "New Commercial Card Request Form submitted for " + this.getField("COMPANYNAME ").valueAsString + " " + this.getField("DATE").valueAsString;,

           cMsg:      var emailMsg = "New Commercial Card Request Form submitted for " + this.getField("COMPANYNAME").valueAsString ;

    })

 

   

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2020 Mar 24, 2020

You didn't actually do what they suggested, and you added new errors into code. 

Here's the corrected code.  Notice how the "cCc:" parameter is a single string. The ";" is inside the string. Not outside. If it's outside the string then it has special meaning to the JavaScript engine, but inside the string it's part of the grouped addresses.  Notice also that I removed the variable declarations. You can't declare varaibles as a object member value.  

 

this.mailDoc({bUI: false
           cTo:"CashManagementProducts@ABC.com",
           cCc:"email1@ABC.com;email2@ABC.com",
           cSubject: "New Commercial Card Request Form submitted for " + this.getField("COMPANYNAME ").valueAsString + " " + this.getField("DATE").valueAsString,
           cMsg:"New Commercial Card Request Form submitted for " + this.getField("COMPANYNAME").valueAsString
    })

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2020 Mar 24, 2020

it is still not accepting the cCc: line. I did change them back to actual email addresses. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2020 Mar 24, 2020

Well, there is a problem with the code, but it's not the cc. The comma is missing from the end of "bUI" parameter.  This would have been the issue first to be reported in the console window. 

I tested this code (fixed the comma) and it works just fine. There is no problem with the cc line.

 

To verify this, change the bUI parameter to true, so you see the result in the email dialog. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2020 Mar 25, 2020
LATEST

Thanks. I did finally get it to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2020 Mar 24, 2020

You should not put a space after the semi-colons, though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 24, 2020 Mar 24, 2020

thanks...  noted.

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