4 Replies Latest reply on Dec 20, 2016 7:06 AM by philmodjunk

    Send attachment with email/multiple users


      My database is hosted and therefore used by multiple users- on PCs and Macs. I have a script that sends an email with a PDF attachment. (Sample.pdf) . The PDF is not generated by Filemaker - just a static file. I have given a copy of this PDF to the other users so it is available from their computer.

      Question: How to I identify the file in the Send Mail script step so that it works for all users? Because I can give the specific file path to Sample.pdf on my computer, the script works as desired. Do I have to get each user to give me the file path on their computer and enter that in the script?


      Thanks for your help.

      Susie Bridges

        • 1. Re: Send attachment with email/multiple users

          I suggest you put the PDF document into a container field and export it to the /temp/ folder as part of the startup or email send script. (But keep track of this process if you do it in the send email so you only do it once). Then when the User sends the email the script already knows where the 'current' copy of the file is located.

          • 2. Re: Send attachment with email/multiple users

            I agree that you should keep exactly one copy of this file in a container field as it will make managing any updates to it much simpler.


            To specify an attachment in the send mail script step, set a variable to the file's filepath, then click the attachment check box and enter the name of the variable in place of the file name.

            • 3. Re: Send attachment with email/multiple users

              Thank you both for your replies, but I am still not sure if I understand the procedure completely. How do I set the file path without exporting it? And then how do I keep from exporting it each time I run the script (as ch0c0halic cautioned against)? Should the container be set up for external storage and then would I use Get (DocumentsPath) to locate file without having to export it? I tried that, but it didn't seem to work...

              I have a table of "resources" containing only one record that I have added the container field to. If I give each user a copy of the PDF to put on their desktop, then could I use Get (DesktopPath) in my variable name? It works on my computer, but not sure if it will work on theirs....

              • 4. Re: Send attachment with email/multiple users

                Set a variable to the current user's temp folder. There's a get function that will give you that path. Append a file name to that path in this calculation.


                Export the the field contents using this $path variable to specify file name and location.


                Now enter your loop where you use send mail and $path to send out your email with this attachment.


                Files exported to the temp folder will not be retained so your users will not be left with copies of this file on their computer once they quit FileMaker.


                Developer hint: there is also a get function for your desktop path. First create this script to use the desktop path so that you can confirm that the file is correctly exported. Once it all works, update your script to use the temporary folder.