4 Replies Latest reply on Feb 28, 2016 10:18 AM by gkaiseril

    attach document from a Folder to mailDoc

    stormforce25

      Hello together

       

      Since a few Days i'm facing a problem about a Report, which I want to make automatical.

       

      Things I want to do automatically:

       

      1. Save full Document in a specifiv Folder (see line 01)

      2. Make all fiels Readonly (see Line 3-6)

      3. Extract first page and save it under a specific folder (see line 8-11) (whole document has 3 Pages)

      4. Mail the document from Point 3 to a Person, with a defined content (see Line 15-24)

       

      Now im Facing the Problem, that it will always takes the Document, which i saved in Line 01.

      I tried the following:

      1. open and close the file in Line 11 --> still not possible

      2. tried to play with active document, because the PDF1ROPage is open, but not active --> still not possible

      3. tried to put a setTimeout after saving the Document in line11, -->was not able to find out, which function I need to use.

      4. tried to ouse bringToFront --> does not work at all

      5. loading an other document, and close it, to get some time to open the document in Line 11 later --> not possible

       

      if I have already a Doument in Path from Line 11 it works with the following command, but it will take the wrong file.

      var otherDoc = app.openDoc("/G/Hapa/Allgemeines/Service Rapport/PDFKunde/" + "PDF1ROPage" + ".pdf");
      

      [pasted after Line 14 and changing Line 24: this.MailDoc --> otherDoc.MailDoc]

       

      I guess it could be made quiet simpel, but due to the point, that I am a newcomer, and tried like 15 hours around. I have to ask the pro's

      Maybe it is also pissible, just to change the attachment of the Mail somehow.

       

      If it is possible I can also upload the File, which i created.

       

      this.saveAs("/G/Hapa/Allgemeines/Service Rapport/TestReport/" + this.getField("AuftragsNr").value + ".pdf") ;
      
      for (var i=0; i<this.numFields; i++) {
          var f = this.getField(this.getNthFieldName(i));
          if (f==null) continue; 
          f.readonly = true;
      }
      this.extractPages({
          nStart: 0,
          nEnd: 0, 
          cPath: "/G/Hapa/Allgemeines/Service Rapport/PDFKunde/" + "PDF1ROPage" + ".pdf"
      });
      this.closeDoc(true);
      try {
          var cToAddr = this.getField("CustomerMail").value;
          var cSubLine = "Service Report of Intervention at " + this.getField("MaschineType").value + "-" + this.getField("MaschineNr").value ;
          var cBody = "Guten Tag" + "\n" +
              "Im Anhang erhalten Sie den Raport vom folgenden Einsatz.\n\n" +
              "Auftragsnummer: " + this.getField("AuftragsNr").value + "\n" +
              "Maschine: " + this.getField("MaschineType").value + "\n" +
              "Seriennummer: " + this.getField("MaschineNr").value + "\n" +
              "Techniker: " + this.getField("Techniker").value + "\n\n" +
              "Bei Fragen sind wir gerne für Sie da.\n";
          this.mailDoc({bUI:false, cTo:cToAddr, cCc:"", cSubject:cSubLine, cMsg:cBody});
      } catch(e){
          app.alert(e);
      }
      
      

       

       

      Thanks a lot for any help.

       

      Best regards

       

      Stefan