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

app.mailMsg bUI parameter "false" ignored

Engaged ,
Feb 25, 2025 Feb 25, 2025

My computer is a Mac, my default email client is Apple Mail and I am using the most recent version of Acrobat DC.

 

I have created an email script with app.mailMsg and the bUI parameter set to false. The body of the message sends a link for a Dropbox file represented by var link . The false parameter is ignored. The message is opened in Apple Mail, composed and ready to send, but requiring user

interaction. The variables in the script are all defined and the link works as intended when clicked in the message.

I need my message to send without user interaction and would appreciate insight / suggestions for accomplishing this. Here is my app.mailMsg script.

 

app.mailMsg(false, attyEM, sendTo, "", "Welcome to ABC", "\r\r" + fn + ":\r\rThank you for accepting our invitation.  Start with this Dropbox link to download essential information about Acrobat and its preferences.\r\r\t" + link + "\r\rEmail us or call if you need help.\r\r");
TOPICS
JavaScript , PDF forms
346
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 ,
Feb 25, 2025 Feb 25, 2025

When the script is not executed from a privileged context (console, action, trusted function in a folder level script) the bUI false parameter is not honored and defaults to true.

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 ,
Feb 25, 2025 Feb 25, 2025

When the script is not executed from a privileged context (console, action, trusted function in a folder level script) the bUI false parameter is not honored and defaults to true.

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
Engaged ,
Feb 25, 2025 Feb 25, 2025

Thank you. 

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
Engaged ,
Feb 25, 2025 Feb 25, 2025

Well, although I'm sure this is the correct answer it's not working for me. I placed the script in a folder level trusted function with everything between app.beginPriv(); and app.endPriv(); but the result is the same, i.e., the script executes everything except actually sending the message without interaction. Therefore I am back to asking for insight as to why the mail message will not send without user interaction. My script has not otherwise changed.

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 ,
Feb 25, 2025 Feb 25, 2025

Can you post your full folder level script and the script you using to call it, and where it is being called from?

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
Engaged ,
Feb 26, 2025 Feb 26, 2025
Question: the app.mailMsg includes a link to a document in Dropbox. Would the presence of the link prevent the message from sending without user interaction? Note: when the composed message is sent to the email client ready to send, the link works as intended.
 
//Calling script: 
this.sendJakNifeLink(gType, gThirdParty, gEntity);
 
That script is called from a mouse up action in a button in a pdf document;
 
//Comment: repeating myself, the script opens a composed email, addressed in the To and cc fields as intended, and sends from the email client with my interaction but does not send without interaction.
 
//Trusted function 
var sendJakNifeLink = app.trustedFunction(function(gType, gThirdParty, gEntity) { 
app.beginPriv();
var fn = this.getField("txtTP." + gType + ".FirstName").valueAsString;
var ln = this.getField("txtTP." + gType + ".LastName").valueAsString;
var co = this.getField("txtTP." + gType + "." + gEntity).valueAsString;
var attyEM = this.getField("txtTP.Atty.E-mail").valueAsString;
var subject = fn + " " + ln + " " + gThirdParty + " data file";
var dataFor = fn + " " + ln + ", " + co;
var sendTo = this.getField("txtL.E-mail").valueAsString;
 
var link = "My link is defined here. I removed it so that it is not included in this post";
if(attyEM != "") {
app.mailMsg(false, attyEM, sendTo, "", "Welcome to JakNife", "\r\r" + fn + ":\r\rThank you for accepting our invitation.  Start with this Dropbox link to download essential information about Acrobat and its preferences.\r\r\t" + link + "\r\rEmail us or call if you need help.\r\rJakNife, LLC\r(309) 824-1154\rFax: (866) 390-4131");
}
 app.endPriv();
}
);
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 ,
Feb 26, 2025 Feb 26, 2025

It worked for me.  What happens when you run the following script in the console:

var mail="put the email address you want to send to here";

app.mailMsg(false, mail, "", "", "Test Email");

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
Engaged ,
Feb 26, 2025 Feb 26, 2025

Copied and pasted from the Console:

var mail = "put the email address you want to send to here";

app.mailMsg(false, mail, "", "", "Test Email");

ReferenceError: mail is not defined

1:Console:Exec

undefined

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 ,
Feb 26, 2025 Feb 26, 2025

You have to replace "put the email address you want to send to here" with an actual email address.

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
Engaged ,
Feb 26, 2025 Feb 26, 2025

I did, but it returned the same error.

ReferenceError: mail is not defined

1:Console:Exec

undefined

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 ,
Feb 26, 2025 Feb 26, 2025

Are running both lines of code?

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
Engaged ,
Feb 26, 2025 Feb 26, 2025

Yes I am running both lines on the Console. Apologies that I keep repeating myself, but my code performs exactly as intended, except for the fact that it is not sending the mail message without user interaction. When I say it performs exactly as intended, I mean the email is composed with the correct email address in the "To" and "cc" fields, the email subject, and the body of the email, exactly as intended. 

Also, I changed my default mail app from Apple Mail to Outlook. Again, the result is the same failure to send without user interaction but otherwise a properly composed mail message. I will be able to test this on a Windows computer over the weekend, in case the OS is the issue.

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 ,
Feb 26, 2025 Feb 26, 2025
LATEST

Yes, I understand all this.  I'm trying to help you troubleshoot to see if the issue is with your trusted function by seeing if a simple email with a false bUI parameter will run from the console.  But now we have a different issue.  The console script is defining the variable mail, but then returning it as undefined in the next line. 

After you run both lines of code again, try selecting only the word "mail" and running that.  Does it still return undefined?  Although it works for me, maybe it is a restricted variable.  Try changing both instances of mail to mail_ and running both lines again.  Now what is returned?

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