3 Replies Latest reply on Feb 5, 2016 3:57 PM by bkgs

    How to email individualised pdfs as attachments to a series of emails


      I want to send subscription invoices to Club members as individualised pdfs attached to an email to each member.  The database is a single file and the finding the records and relevant fields is not a problem.  However I am having trouble working out how to specify the name and temporary file path of the pdfs to be created using a script to send individualised invoices to a each of the email recipients. 


      I start with a script that finds the relevant records and opens a layout that sets out the individualised invoice for each found record. 


      I then started to do another script to create the pdfs and send the emails which runs as follows:


      Go to Layout


      Go to Record/Request/Page [First]

      Save Records as PDF [Restore; No Dialog; (problem - how to name the pdf for the first email recipient  The naming seems to be in Specify Options - Save Current Record - Current Record - Options  -Title I have checked Specify Output File and Specify Options (problem Specify Output File requires a suitable temporary file path for the pdf yet to be created.  No need for the pdf to be retained as the FM record is adequate}

      Send Mail [Send via E-Mail Client; To (field in relevant record identifying recipient's email address); Subject: " Blah Blah"; Message: (more "Blah Blah" ); (pdf name as above) Send Mail Options Send via E-Mail Client  Create one email using data from the Current Record - Subject - Message     - Attach file - Specify file path (problem??)

      Go to Record etc [Next]

      Repeat Save Records as above (but how do I name each successive email recipient's pdf and describe the file path )

      Send Mail (as above)

      Go to Record etc [Next:Exit after Last]

      End Loop

      Allow User Abort


      I hope the foregoing is sufficient to demonstrate my difficulties.  Any guidance would be appreciated.

        • 1. Re: How to email individualised pdfs as attachments to a series of emails

          Hi.  A couple of comments and then I've posted a screenshot of a sample script.

          1.  Make sure you move your Go to Record/Request/Page [First] before you start your loop or you will end up in an endless loop, because the way you have it at the moment its going to keep going back to the first record at the beginning of the loop.

          2.  I find it easier to set the pdf filename as a variable and then use that in specifying the filename variable.  Then you use the filename variable in the save records as pdf and in the send email steps.

          3.  You can actually specify the Save Records as PDF with an option to open the pdf in an email after it has created it, but I prefer having the send mail step as an explicit separate step.

          4.  Make sure your "Send Mail" options are set to Create:  One email using data from the current record.

          Screen Shot 2016-02-05 at 10.21.42 PM.png

          HTH.  Chris

          • 2. Re: How to email individualised pdfs as attachments to a series of emails

            Many thanks Chris. 


            This is gets right to the heart of my problems.  However there is a glitch.  When I set the script up as you suggest the first email comes out as intended with the correct address and attachment but for the next email whilst the correct party is addressed  the pdf attached is that which was created for the first record.  Is there something else I need to do to refresh the temporary path.  Repeating the Save Records step after the Go to Next Record step didn't make any difference.


            A separate issue is that when the message gets to Mail the attachment is placed prior to the message.  That may be something due to the set up of Apple Mail rather than Filemaker.  Not sure but it is minor issue.

            • 3. Re: How to email individualised pdfs as attachments to a series of emails

              I think I may have solved the problem.  If I add another $ symbol in front of FilePath to make it  globally available it seems to work as intended.  I will have to set up live performance to be sure.