3 Replies Latest reply on Jun 28, 2016 2:51 PM by jrenfrew

    Saving Record as pdf and Sending it with Send Mail

    lacomunidadnews

      I have been working on a script that saves the current record as a pdf file and sends it automatically via FileMaker's Send Mail script.

       

      I have tried doing:

       

      Set Variable [$Output; Value: Get( TemporaryPath ) & “sample.pdf”]

      Save Records as PDF [No dialog; “$Output”; Records being browsed]

      Send Mail [Send via E-mail Client; To: “ex@example.com”; Subject: “Invoice” ; Message: “Test”; “$Output”]

       

      as directed by FileMaker support, but still the pdf does not attach, and I am wondering if it is even saving the file because I can not find it in the same directory that FileMaker is in.

       

      I also tried this -

       

      Save Records as PDF [No dialog; “receipt.pdf”; Records being browsed]

      Set Variable [$Output; Value: Get( TemporaryPath ) & “receipt.pdf”]

      Send Mail [Send via E-mail Client; To: “ex@example.com”; Subject: “Invoice” ; Message: “Test”; “$Output”]

       

      Here I find the receipt.pdf file in the same directory that FileMaker is in, but the email still has no attachment when received. Any help would be awesome, thanks!

        • 1. Re: Saving Record as pdf and Sending it with Send Mail
          mgeerdes

          Hello,

          The top example is the correct way of doing it. The file will not be in the same directory as FileMaker, as you are telling it to use the TemporaryPath, which is a temporary directory in your system Folder.

          In the second example, you are saving it, and then telling your variable to look in a completely different location for the file (TemporaryPath), so that's not going to work.

           

          If you have FileMaker Pro Advanced, use the Script Debugger and Data Viewer to make sure that your $Output has the correct format that will work with your OS for Send Mail. To see the correct formats, when you are in the Send Mail Specify box in the script, hit the Specify button next to the Attach file checkbox, at the bottom, you will see path examples. My guess is that your path would have to be similar to those examples.

           

          If you don't have Advanced, you can add a show custom dialogue command and put your variable into it and run the script.

           

          Good luck, hope this helps.

          • 2. Re: Saving Record as pdf and Sending it with Send Mail
            Benjamin Fehr

            … and with Mac, the Attachment maybe won't be included properly if Script is set to

                 Send Mail [ Send via Email Client ; With Dialog: Off ]

            • 3. Re: Saving Record as pdf and Sending it with Send Mail
              jrenfrew

              path is wrong..

              output ->

              "file:" & Get ( TemporaryPath ) etc

               

              if you want to check if the file is created change to Get ( DocumentsPath ) while you are testing , then you can see the file

               

              just because you are using a variable in the file path, it still needs to be like the examples that are in the actual dialog box

               

              Screen Shot 2016-06-28 at 22.53.01.png