12 Replies Latest reply on Feb 2, 2010 1:40 PM by TSGal

    Combining the the Save  Record as PDF Script with Send Mail Script

    Elm

      Title

      Combining the the Save  Record as PDF Script with Send Mail Script

      Post

      <!--  StartFragment  -->

      I am running OS 10.5.8 with FM Pro 9 and no networks or publishing.  I have used Save Records as PDF to create a Script, which works great. I have used Send Mail to create a second Script, which also works great.  When I run these 2 Scripts“manually” one right after the other they work fine, but for multiple records I have to run each Script each time, for each for record, I wish to save and then send.

       

      The problem occurs when I create a thirdScript to run both of the above Scripts together.  It appears the PDF fille gets “saved,” but the Send Mail Script appears to delete the “saved” PDF file as it begins to run, as it does not get attached, and it is missing from the folder where the Save Script put it once the Send Mail Script finishes.<!--  EndFragment  -->

        • 1. Re: Combining the the Save  Record as PDF Script with Send Mail Script
          philmodjunk
             I suspect that Filemaker doesn't wait for the save to PDF to complete before turning around and trying to email it in the next step. Experiment and see what happens if you add a Pause/Resume step that specifies a pause of several seconds in between the "save" and the "send".
          • 2. Re: Combining the the Save  Record as PDF Script with Send Mail Script
            Elm
               I have already thought of that and tried it (60 sec) with ame results
            • 3. Re: Combining the the Save  Record as PDF Script with Send Mail Script
              philmodjunk
                 Also, don't know if Filemaker 9 has the same feature, but Filemaker 10 has a "create email with file as attachment" option that may enable you to combine the two actions in a way that avoids the issue.
              • 4. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                Elm
                   The FM 9 Send Mail also does that.  I am tring to save a record as a PDF then Send that same PDF with Send Mail
                • 5. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                  TSGal

                  Elm:

                   

                  Thank you for your post.

                   

                  I have several scripts for Save As PDF and Send Mail with attachment, and I do not have a problem in either FileMaker Pro 9 or FileMaker Pro 10.

                   

                  Is it possible you are saving the file to a different folder than expected and/or attaching the file from a different folder?

                   

                  Can you post your script steps with all the options?  This may help narrow down the possible cause.

                   

                  TSGal

                  FileMaker, Inc. 

                  • 6. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                    deltatango
                       Why don't you just use the Get (TempFolder) and save a new pdf with the send mail step? It will delete the temp file automatically, regardless of the other save as pdf step. 
                    • 7. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                      mrtmcfly
                        

                      I don't have any professional training,Im self taught but this is my solution for the problem. There may be an easier way to accomplish it but it works.

                       

                      Email Proposal
                      Go to Layout [ “proposal” (proposal) ]
                      Copy [ proposal::proposal num ]
                      [ Select ]
                      Enter Find Mode [ ]
                      Paste [ proposal::proposal num ]
                      [ Select ]
                      Perform Find [ ]
                      If [ proposal::BODY CATEGORY = 100 ]
                      Go to Layout [ “Print Roll Off Proposal Proposal” (proposal) ]
                      Enter Preview Mode
                      Set Variable [ $filename; Value:proposal::pdf file name ]
                      Save Records as PDF [ File Name: “file://server4/salesfiles$/Proposals - 2010/$filename”; Automatically open; Records being
                      browsed ]
                      [ Document - Compatibility: Acrobat 5 and later ]
                      [ Pages - Number Pages From: 1; Include: All pages ]
                      [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ]
                      [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]
                      [ Restore ]
                      Send Mail [ To: proposal::Email; Subject: "Proposal #" & proposal::proposal num; Attachment: “file://server4/salesfiles$/Proposals -
                      2010/$filename” ]
                      Go to Layout [ “proposal” (proposal) ]
                      Enter Browse Mode
                      Exit Script [ ]
                      End If
                      Go to Layout [ “Print Proposal” (proposal) ]
                      Enter Preview Mode
                      [ Pause ]
                      Set Variable [ $filename; Value:proposal::pdf file name ]
                      Save Records as PDF [ File Name: “file://server4/salesfiles$/Proposals - 2010/$filename”; Automatically open; Records being browsed ]
                      [ Document - Compatibility: Acrobat 5 and later ]
                      [ Pages - Number Pages From: 1; Include: All pages ]
                      [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ]
                      [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]
                      [ Restore; No dialog ]
                      Send Mail [ To: proposal::Email; Subject: "Proposal #" & proposal::proposal num; Attachment: “file://server4/salesfiles$/Proposals - 2010/
                      $filename” OR “file://server4/salesfiles$/Specs and Pricing/SPEC SHEETS 7-2009/BROCHURE.pdf” ]
                      Go to Layout [ “proposal” (proposal) ]
                      Enter Browse Mode
                      February



















                      • 8. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                        Elm
                          

                        TSGal:

                         

                        Thanks for the post. I am using FM Pro 9.  The files going to and coming from the same folder.  Below is the script that does not function correctly.

                        Save PDF 1 at a time to Email Combo (this is the scripts name)

                        Go to Record/Request/Page

                        [ First ]

                        Loop

                        Perform Script [ “Save PDF 1 at a time #1” ]

                        Perform Script [ “Email 1 at a time #2” ]

                        Go to Record/Request/Page

                        [ Previous ]

                        Go to Record/Request/Page

                        [ Next; Exit after last ]

                        End Loop

                        Go to Layout [ original layout ]

                        Allow User Abort [ On ]

                         

                        Now if manually run the script "Save PDF 1 at a time #" it works fine.  If I immediately manually run the script "Email 1 at a time#2" to too works fine and attachs the PDF file to the Email.  However, when I run the script shown above it sets up the Email, but does not attach the file.  When I go back and look in the folder where the PDF is temporarily held it is gone (it has been deleted, because if I check this fold after I run the first script the PDF file is there).  I created the separeate "Perform Script" scripts (they are each the single step to accummplish the Save as PDF and Eamil tasks) as part of my trouble shooting process, otherwise the there would only be the 2 differnt steps

                         

                        I hope this is clear.

                         

                        • 9. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                          TSGal

                          Elm:

                           

                          Thank you for the script.

                           

                          I don't see why you go to the previous record and then the next record.  This should cause an infinite loop.  Regardless, here is a loop that I have that works on my machine.

                           

                          Go to Record/Request/Page [ First ]

                          Loop

                             Save Records as PDF [ Restore ; No dialog ; "temp.pdf" ; Current record ]

                             Send Mail [ Send via E-mail Client ; To: <table> :: <email field> ; Subject: <literal text> ; Message: <literal text> ; "temp.pdf" ]

                             Go to Record/Request/Page [ Next ; Exit after last ]

                          End Loop

                           

                          ---------

                           

                          It appears this is almost identical to your script, but I do not see your location of where the file is saved, nor if the filename is static or dynamically named.  My script uses a static filename in a static location.

                           

                          Any other information you can provide may be helpful.

                           

                          TSGal

                          FileMaker, Inc. 

                          • 10. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                            Elm
                              

                            TSGal:

                             

                            Thank you for the script, i will give it a try.  in the mean time here are the   2 other "scripts"

                             

                            Save PDF 1 at a time #1

                            Save Records as PDF [ File Name: “file:../ ITALY Caravan/IM PDF Holder/ Reservation.pdf”; Current record ]

                            [ Document - Compatibility: Acrobat 5 and later ]

                            [ Pages - Number Pages From: 1; Include: All pages ]

                            [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ]

                            [ Initial View - Show: Pages Panel and Page; Page Layout: Single Page; Magnification: 100% ]

                            [ Restore ]

                             

                            Email 1 at a time #2

                            Send Mail [ To: CG Info::Email; Subject: "Reservation Request"; Message: "Dear Sir or Madam,¶¶Please see our attached PDF

                            request for a reservation file¶¶Thank you,¶¶Jim & Sally Elmlinger¶Burbank, CA¶"; Attachment: “file:../ ITALY Caravan/IM PDF

                            Holder/ Reservation.pdf” OR “file:../ ITALY Caravan/IM PDF Holder/ Italian earthquake 4%2F5%2F09 copy.pdf” OR “file:../ ITALY

                            Caravan/IM PDF Holder/ Reservation.pdf” ]

                             

                            Please let me know if you find anything a miss. 

                             

                            • 11. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                              Elm
                                

                              PS: TSGal:

                               

                              You are correct in that the "previous" is incorrect and is left over from my playing around with different things to try and get to work.  It is supposed to the "next" record.

                               

                              Thanks again for you help and interest it is greatly appreciated.

                               

                              Elm 

                              • 12. Re: Combining the the Save  Record as PDF Script with Send Mail Script
                                TSGal

                                Elm:

                                 

                                The scripts look fine, even with the first and third attachment being the identical path and filename.

                                 

                                You may want to consider putting the file path and filename into a variable, and then move the two scripts up one level and reference the variable.  For example,

                                 

                                Set Variable [ $path ; "file:Reservation.pdf" ]

                                Save Records as PDF [ File Name: $path ; current record ; etc....]

                                Send Mail [ To: CG Info::Email ; .......  Attachment: $path ]

                                 

                                -----

                                 

                                This ensures the file is exported and imported from the same place.

                                 

                                TSGal

                                FileMaker, Inc.