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

Javascript to send e-mail with Attachments

Explorer ,
Nov 04, 2023 Nov 04, 2023

Hello,

 

I have the following JS saved into the Javascript's Folder:

 
var sendEmailWithAttachment = app.trustedFunction(function(doc) {
   
    app.beginPriv(); // Inizia l'esecuzione privilegiata
    var textName = doc.getField("TEXT").value;
    var path = "G:\\Il mio Drive\\FOLDER\\" + textName;
    var files = {
        "Check Box1": path + "\\DOC1.pdf",
        "Check Box2": path + "\\DOC2.pdf",
        "Check Box3": path + "\\DOC3.pdf",
    };
    var email = {
        cTo: "emailaddress@gmail.com",
        cSubject: "This text" + textName,
        cMsg: "Message to be written into the e-mail's body",
    };
    for (var checkbox in files) {
        if (doc.getField(checkbox).value === "Yes") {
            email.cAttachment = files[checkbox];
        }
    }

    email.bUI = true;
    this.mailDoc(email);

    app.endPriv(); });
 
I call this function into my document through an action of a Button: sendEmailWithAttachment(this);
 
Unfortunately the magic doesn't happen, meaning: further the same doc from which I'm working, no further attachments appear into the e-mail.
Do you have any suggestions? Anytime I heard someone saying "this can't be done", I kept looking for a solution and I reached the task. So, please just help me understand what to do here. Thank you in advance

 

TOPICS
How to , JavaScript , Modern Acrobat , PDF , PDF forms
1.1K
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 ,
Nov 04, 2023 Nov 04, 2023

The function mailDoc has no parameter with the name cAttachment.

 

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
Explorer ,
Nov 04, 2023 Nov 04, 2023

Thank you, so which parameter shoul I use ? Or do I have to use another function to send the e-mail, that includes a parameter also to attach files ?

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 ,
Nov 04, 2023 Nov 04, 2023
LATEST

This is not possible to do with a script.

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